【问题标题】:WSO2 ESB Proxy CRLF normalized to LFWSO2 ESB 代理 CRLF 标准化为 LF
【发布时间】:2016-01-13 22:11:19
【问题描述】:

一个只添加身份验证的简单代理。

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="QueryTestProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property xmlns:ns="http://org.apache.synapse/xsd"
                   name="Authorization"
                   expression="fn:concat('Basic ', base64Encode(fn:concat('admin:', wso2:vault-lookup('QueryTest'))))"
                   scope="transport"
                   type="STRING"/>
         <send>
            <endpoint key="conf:/QueryTest"/>
         </send>
      </inSequence>
      <faultSequence>
         <send/>
      </faultSequence>
   </target>
   <publishWSDL key="conf:/WSDL/QueryTest.wsdl"/>
   <description/>
</proxy>

端点服务在其中一个字段上对 CRLF 进行拆分,并且端点不能被修改并且不能使用 CDATA。

问题是 WSO2 ESB 总是用 LF 替换 CRLF 并且拆分不起作用,有没有人知道如何阻止 WSO2 ESB 来规范化消息?

【问题讨论】:

    标签: wso2 axis2 wso2esb


    【解决方案1】:

    ESB 的 XML 解析器 (AXIOM) 只是按照 XML 规范工作

    http://www.w3.org/TR/REC-xml/#sec-line-ends

    所以 XML 解析器必须用 LF 替换 CR-LF。这在上面的 XML 规范中有所提及。

    这就是wso2 ESB中用LF替换CRLF的原因

    【讨论】:

      【解决方案2】:

      Axiom 使用 stax 和 stax 删除 CR-LF 中的那些 CR

      从这样生成的肥皂消息中编写文本文件时,我遇到了类似的问题:

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:guid="http://com/cylande/unitedretail/guidedsale/service/common/GuidedSaleManagerService/">
         <soapenv:Header/>
         <soapenv:Body>
            <text xmlns="http://ws.apache.org/commons/ns/payload">my flat datas whith carriage return and line feeds</text>
         </soapenv:Body>
      </soapenv:Envelope>
      

      我们应该能够配置此行为,在 ESB_HOME 中创建一个 XMLOutputFactory.properties 文件,其内容为:com.ctc.wstx.outputEscapeCr=false 但就我而言,我无法再启动 ESB...

      (详情请见http://ws.apache.org/axiom/apidocs/org/apache/axiom/om/util/StAXUtils.html)

      这是我在调用 send mediator 之前在中介中添加的 javascrip:

      <script language="js"><![CDATA[
              try {           
                  var payloadXML = mc.getPayloadXML();            
                  var envelopeXML = mc.getEnvelope();         
                  if (payloadXML != null) {               
                      var text = payloadXML.toString();               
                      if ((envelopeXML != null) && (envelopeXML.getBody() != null) && (envelopeXML.getBody().getFirstElement() != null))                          
          // Do not use mc.setPayloadXML(), it depends on Stax that delete the carriage return we are trying to add...
                          envelopeXML.getBody().getFirstElement().setText(text.replace(new RegExp('\n','g'),'\r\n'));         
                  }       
              } catch (e) {           
              }
      ]]></script>
      

      希望您能够根据需要调整此脚本。

      【讨论】:

      • 我尝试使用 javascript 中介,它在该节点的文本中将 LF 替换为 CRLF,但是当消息发送时,它被替换为 LF。
      猜你喜欢
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-15
      • 1970-01-01
      • 2012-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多