2015-10-15 60 views
2

僅添加認證的簡單代理。標準化爲LF的WSO2 ESB代理CRLF

<?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規範化消息的方法嗎?

回答

0

ESB的XML解析器(AXIOM)根據XML規範

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

所以XML解析器必須以LF替換CR-LF只是工作。這在上面的XML規範中提到過。

這是WSO2與LF取代CRLF ESB

的原因
2

公理使用STAX和STAX刪除那些CR在CRLF

我已經從肥皂寫文本文件時,也有類似的問題

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

我們應該能夠配置此行爲創建XMLOutputFactory.properties文件中ESB_HOME,與此內容:合作這樣的消息產生m.ctc.wstx.outputEscapeCr =假 但在我的情況下,我不能夠再啓動ESB ...

(詳情請參見http://ws.apache.org/axiom/apidocs/org/apache/axiom/om/util/StAXUtils.html

這裏是的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> 

希望你能夠給該腳本適應你的需要:「已經在我的調解調用send調解前加入。

+0

我試過使用javascript mediator,它在該節點的文本中用CRLF替換LF,但是當發送消息時,它將用LF替換回來。 –