如何使用Xpath检索Wso2esb中的值

时间:2013-11-08 07:53:42

标签: xpath wso2 wso2esb wso2carbon xpath-2.0

我正在使用wso2esb4.7.0我写了jms代理所以我希望将我的数据发送到端点但我无法处理这个 我的代理是

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="MediaMoveQueue"
       transports="jms"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <property name="readingspayload" expression="$body"/>
         <payloadFactory media-type="xml">
            <format>
               <p:hello xmlns:p="http://jaxws.youtility.in/">
                   <arg0 xmlns="">$1</arg0>
               </p:hello>
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('readingspayload')"/>
            </args>
         </payloadFactory>
         <!--header name="Action" value="hello"/-->
         <log level="full"/>
         <send>
            <endpoint>
               <address uri="http://192.168.1.2:8282/services/media_move_service_i_f"
                        format="soap11"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
</proxy>

在这个代理中我得到这样的数据如果我记录这个esb 我的日志看起来像这样

  


         { “时间戳”:1383715637698, “tmpfilename”: “313d79a7-c29b-4e1a-9609-818610a6a66b.pdf”, “OBJECTTYPE”: “打孔”, “文件名”: “enterprisedb_order.pdf”, “totalfilesize”:994086,” UUID “:” 313d79a7-c29b-4e1a-9609-818610a6a66b “ ”的objectid“: ”313d79a7-c29b-4e1a-9609-818610a6a66b“, ”FULLPATH“:”/ TMP / tmpmedia // 313d79a7-c29b-4e1a-9609- 818610a6a66b.pdf”, “设备ID”: “911202500210109”, “filemimetype”: “PNG”}    

但是我需要将json格式的数据发送到我的端点,因为我已经尝试过这个xpath但是它显示了名称空间的错误我将如何获得这个

$axis2ns58:text

但是它的抛出错误我希望将该数据发送到我的端点 我试过这个,但我只需要上面的数据格式

//soapenv:Body

它给出了这样的结果

   <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
      <axis2ns58:text xmlns:axis2ns58="http://ws.apache.org/commons/ns/payload">{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}</axis2ns58:text> 
</soapenv:Body>

但我希望将以下数据发送到我的终端,即使有效负载也不支持此

{"timestamp":1383715637698,"tmpfilename":"313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","objecttype":"Punch","filename":"enterprisedb_order.pdf","totalfilesize":994086,"uuid":"313d79a7-c29b-4e1a-9609-818610a6a66b","objectid":"313d79a7-c29b-4e1a-9609-818610a6a66b","fullpath":"/tmp/tmpmedia//313d79a7-c29b-4e1a-9609-818610a6a66b.pdf","deviceId":"911202500210109","filemimetype":"PNG"}

2 个答案:

答案 0 :(得分:2)

您可以尝试

//soapenv:Body/ns:text

并设置命名空间

ns="http://ws.apache.org/commons/ns/payload"

答案 1 :(得分:0)

试试这个: 修改您的代理服务,如下所示:

而不是<property name="readingspayload" expression="$body"/> , modify it to below, <property xmlns:ns="http://ws.apache.org/commons/ns/payload" name="readingspayload" expression="$body/ns:text/text()"/>

 ****

希望这应该有用!!!