1

I want to use the following xpath

/Users/User/UserID

This does not work because the ESB adds a soap envelope and body around my xml, what is the correct xpath to use or how can I remove the soap envelope and body?

The xml is:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <Users xmlns="http://ws.wso2.org/dataservice">
         <User>
            <UserID>a</UserID>
            <Username>a</Username>
            <Email>a</Email>
            <Password>a</Password>
         </User>
         <User>
            <UserID>a</UserID>
            <Username>a</Username>
            <Email>a</Email>
            <Password>a</Password>
         </User>
         <User>
            <UserID>a</UserID>
            <Username>a</Username>
            <Email>a</Email>
            <Password>a</Password>
         </User>
      </Users>
   </soapenv:Body>
</soapenv:Envelope>

EDIT:

This works when I try to log it outside of my iterate mediator

//*[local-name() = 'Users']/*[local-name() = 'User']/*[local-name() = 'UserID']

but when I try to log it inside the iterate mediator it returns nothing?

4

3 回答 3

1

通过使用以下方法得到这个工作

<property xmlns:int="http://ws.wso2.org/dataservice" name="uri.var.ID" expression="$body/int:User/int:UserID/text()" scope="default" type="STRING"/>
于 2014-08-01T14:01:45.773 回答
0

尝试这个:

<property name="yourParamName" expression="$body/Users/User/UserID" scope="default" type="STRING"/>

您可以在此处阅读有关预定义 Synapse XPath 变量的更多信息。

于 2014-07-31T15:54:10.073 回答
0

要访问您的元素,您应该通过信封和正文。下面是一个使用 switch 中介的例子:

<switch xmlns:ns="http://org.apache.synapse/xsd" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:int="http://ws.wso2.org/dataservice" 
        source="boolean(/soap:Envelope/soap:Body/int:Users/int:User/int:UserID/text() = 'string_to_compare'">
  <case regex="true">
     ....
  </case>
  <default/>
</switch>

UPD 更正的 XPath 表达式

于 2014-07-30T14:36:22.517 回答