2013-12-11 83 views
0

我已經使用XSLT配置了變壓器代理。我的XSLT表達式已經過測試,它們是正確的。但是會發生「意外的子元素值」錯誤。請幫我解決這個問題。WSO2 ESB 4.7 - 變壓器代理錯誤

代理

<proxy name="testProxy" transports="http" startOnLoad="true" trace="disable"> 
     <target> 
     <endpoint> 
      <address uri="http://localhost:8080/axis2/services/hello2"/> 
     </endpoint> 
     <inSequence> 
      <log level="full"/> 
      <xslt key="req"/> 
     </inSequence> 
     <outSequence> 
      <log level="full"/> 
      <xslt key="res"/> 
      <send/> 
     </outSequence> 
     </target> 
    </proxy> 

    <localEntry key="res" src="file:repository/resources/test/res.xsl"/> 
    <localEntry key="req" src="file:repository/resources/test/req.xsl"/> 

ESB日誌

[2013-12-12 03:25:58,904] INFO - LogMediator To: /services/testProxy, WSAction: sayHello, SOAPAction: sayHello, MessageID: urn:uuid:aef12421-abad-4a87-ba7b-4c13012a4a4a, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns1:value xmlns:ns1="http://tempuri.org/hello1">Peter</ns1:value></soapenv:Body></soapenv:Envelope> 
[2013-12-12 03:25:58,916] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:43cc7c61-29ee-4827-ba5e-735af5ecbd00, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><soapenv:Fault><soapenv:Code><soapenv:Value>soapenv:Receiver</soapenv:Value></soapenv:Code><soapenv:Reason><soapenv:Text xml:lang="en-US">org.apache.axis2.databinding.ADBException: Unexpected subelement {http://tempuri.org/hello1}value</soapenv:Text></soapenv:Reason><soapenv:Detail/></soapenv:Fault></soapenv:Body></soapenv:Envelope> 

req.xsl

<?xml version="1.0" encoding="UTF-8"?> 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" 
xmlns:ns1="http://tempuri.org/hello1" 
xmlns:ns2="http://tempuri.org/hello2"> 

    <xsl:output method="xml" indent="yes"/> 

    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="/soapenv:Envelope/soapenv:Body/ns1:value"> 
     <ns2:stringValue> 
      <xsl:value-of select="normalize-space(.)" /> 
     </ns2:stringValue>    
    </xsl:template> 

</xsl:stylesheet> 

res.x SL

<?xml version="1.0" encoding="UTF-8"?> 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" 
xmlns:ns1="http://tempuri.org/hello1" 
xmlns:ns2="http://tempuri.org/hello2"> 

    <xsl:output method="xml" indent="yes"/> 

    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="/soapenv:Envelope/soapenv:Body/ns2:stringValue"> 
     <ns1:value> 
      <xsl:value-of select="normalize-space(.)" /> 
     </ns1:value>    
    </xsl:template> 

</xsl:stylesheet> 

回答

0

SOAP錯誤是從您的端點的反應,你應該在你的inSequence中<xslt key="req"/>後添加日誌級別=「滿」看你送什麼

+0

我添加了一個日誌級別=「全「 如你所說。傳入的消息尚未轉換。但是XSLT文件是正確的。可能是什麼原因? – user3049576

+0

肥皂信封和身體必須被忽略到您的轉換中,xsl適用於從Body的第一個孩子開始的XML樹上 –