0

我正在使用 wso2esb 4.7.0 和 wso2dss3.0.1 我正在获取正确的数据但无法发送到客户端。问题是无法转换消息我的消息显示错误本地条目是 xslt 文件

    <?xml version="1.0" encoding="UTF-8"?>
    <localEntry xmlns="http://ws.apache.org/ns/synapse" key="emp_xslt">
       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                       xmlns:f="http://ws.wso2.org/dataservice"
                       version="1.0">
          <xsl:output method="xml"/>
          <xsl:param name="eage"/>
          <xsl:param name="eno"/>
          <xsl:template match="/">
             <xsl:apply-templates select="/f:empCollection"/>
          </xsl:template>
          <f:for-each select="//f:emp">
             <tr>
                <eage>
                   <xsl:value-of select="eage"/>
                </eage>&gt;
              <eno>
                   <xsl:value-of select="eno"/>
                </eno>
             </tr>
          </f:for-each>
       </xsl:stylesheet>
       <description/>
</localEntry>

xslt 配置是这样的

<sequence xmlns="http://ws.apache.org/ns/synapse" name="emp2">
   <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:s="http://ws.wso2.org/dataservice" name="eno" expression="//s:empCollection/s:emp/s:eno" scope="default" type="STRING"/>
   <property xmlns:ns="http://org.apache.synapse/xsd" xmlns:s="http://ws.wso2.org/dataservice" name="eage" expression="//s:empCollection/s:emp/s:eage" scope="default" type="STRING"/>
   <log level="full">
      <property name="response" value="not working"/>
      <property xmlns:ns="http://org.apache.synapse/xsd" name="eno" expression="get-property('eno')"/>
      <property xmlns:ns="http://org.apache.synapse/xsd" name="eage" expression="get-property('eage')"/>
   </log>
   <xslt xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" key="emp_xslt" source="/f:empCollection/f:emp">
      <property name="eno" expression="get-property('eno')"/>
      <property name="eage" expression="get-property('eage')"/>
   </xslt>
   <log level="full"/>
</sequence>

但我希望向客户端显示数组数据格式我像这样从 esb 获取数据

Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><empCollection xmlns="http://ws.wso2.org/dataservice"><emp><ename>faisal</ename><eno>5</eno><eage>26</eage></emp><emp><ename>suresh</ename><eno>6</eno><eage>26</eage></emp><emp><ename>prashant</ename><eno>7</eno><eage>28</eage></emp><emp><ename>anil</ename><eno>2</eno><eage>27</eage></emp><emp><ename xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><eno>0</eno><eage>0</eage></emp><emp><ename>-1</ename><eno>0</eno><eage>0</eage></emp></empCollection></soapenv:Body></soapenv:Envelope>

并且我的 esb 日志正在评估控制台中的许多错误,它有时会显示 xpath 错误 name=null 是否可以制作我的数据数组

[2013-10-10 15:07:44,425]  INFO - LogMediator To: /services/xsltExmp, MessageID: urn:uuid:619c7f86-f0d1-4f57-935b-66b485f8fa08, Direction: request
[2013-10-10 15:07:44,440]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:9f8bf2a6-5736-48c9-bda5-c163c6c571d6, Direction: response, response = not working, eno = 567200, eage = 2626282700, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><empCollection xmlns="http://ws.wso2.org/dataservice"><emp><ename>faisal</ename><eno>5</eno><eage>26</eage></emp><emp><ename>suresh</ename><eno>6</eno><eage>26</eage></emp><emp><ename>prashant</ename><eno>7</eno><eage>28</eage></emp><emp><ename>anil</ename><eno>2</eno><eage>27</eage></emp><emp><ename xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><eno>0</eno><eage>0</eage></emp><emp><ename>-1</ename><eno>0</eno><eage>0</eage></emp></empCollection></soapenv:Body></soapenv:Envelope>
[2013-10-10 15:07:44,442] ERROR - XSLTMediator The evaluation of the XPath expression /f:empCollection/f:emp did not result in an OMNode : null
[2013-10-10 15:07:44,442] ERROR - XSLTMediator Unable to perform XSLT transformation using : Value {name ='null', keyValue ='emp_xslt'} against source XPath : /f:empCollection/f:emp reason : The evaluation of the XPath expression /f:empCollection/f:emp did not result in an OMNode : null
org.apache.synapse.SynapseException: The evaluation of the XPath expression /f:empCollection/f:emp did not result in an OMNode : null
    at org.apache.synapse.util.xpath.SourceXPathSupport.selectOMNode(SourceXPathSupport.java:100)
    at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:211)
    at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:191)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:114)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:232)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:443)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:166)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:222)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)
[2013-10-10 15:07:44,444]  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:9f8bf2a6-5736-48c9-bda5-c163c6c571d6, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Unable to perform XSLT transformation using : Value {name ='null', keyValue ='emp_xslt'} against source XPath : /f:empCollection/f:emp reason : The evaluation of the XPath expression /f:empCollection/f:emp did not result in an OMNode : null, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><empCollection xmlns="http://ws.wso2.org/dataservice"><emp><ename>faisal</ename><eno>5</eno><eage>26</eage></emp><emp><ename>suresh</ename><eno>6</eno><eage>26</eage></emp><emp><ename>prashant</ename><eno>7</eno><eage>28</eage></emp><emp><ename>anil</ename><eno>2</eno><eage>27</eage></emp><emp><ename xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><eno>0</eno><eage>0</eage></emp><emp><ename>-

100

4

1 回答 1

0

由于 ypu 需要 xslt 中介器中的所有 emp 元素,因此请从 XSLT 中介器中删除 source 属性,如下所示。

<xslt xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" key="emp_xslt">
      <property name="eno" expression="get-property('eno')"/>
      <property name="eage" expression="get-property('eage')"/>
   </xslt>
于 2013-10-10T17:53:35.887 回答