WSO2 ESB代理CRLF归一化为LF

时间:2015-10-15 12:36:50

标签: wso2 axis2 wso2esb

仅添加身份验证的简单代理。

<?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规范化消息的方法?

2 个答案:

答案 0 :(得分:2)

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

在从如下生成的soap消息中编写文本文件时,我遇到了类似的问题:

<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>

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

答案 1 :(得分:0)

ESB的XML解析器(AXIOM)正在根据XML规范进行工作

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

因此XML解析器必须用LF替换CR-LF。这在上面的XML规范中提到。

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