4

我正在 WSO2 ESB 中开发代理服务。

使用此配置,我检索 xml Web 服务响应。响应使用默认命名空间,如下所示:

<enrich>
<source type="body" clone="true" />
<target type="property" property="soapXmlResponseReadCahceDataService" />
</enrich>

这是 xml 响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body>
<cacheServices **xmlns="http://cache.services"**>
<cacheService>
   <id>1</id>
   <xmlrequesthash>b1e97b67-1226-4b1d-9081-b2a140690efd</xmlrequesthash>
   <xmlrequestpayload>c</xmlrequestpayload>
   <xmlresponsepayload>d</xmlresponsepayload>
   <quantity>1</quantity>
   </cacheService>
</cacheServices>
</soapenv:Body> </soapenv:Envelope>

此后我需要获取元素数量

<property xmlns="http://cache.services" name="count" expression="//cacheServices/cacheService/quantity" />

WSO2 ESB 不允许您放置没有前缀的命名空间,而且我无法获得该值。我可以获取这个值,因为 xml 响应没有命名空间前缀?

4

1 回答 1

1

Can you try this xpath in property mediator ?

 <property name="count" expression="//*[name()='cacheServices']/*[name()='cacheService']/*[name()='quantity']" scope="default" type="STRING"/>

Alternatively you can use this by adding any namespace prefix since you are using default namespace.

 <property xmlns:ns1="http://cache.services" name="count" expression="//ns1:cacheServices/ns1:cacheService/ns1:quantity" scope="default" type="STRING"/>
于 2012-10-29T10:08:14.507 回答