Yasothar
Yasothar

Reputation: 453

WSO2ESB, XPath, split values based on a token in SOAP response

I have a SOAP response message which contains a node value similar to string A_B_C_D. I need to split each value based on the underscore (_) and set them in separate properties.

I checked with Xpath tokenize function but could not find a way to get the values like array[1], array[2].. separately. I also did some reading on XSLT mediator but not sure whether it will help me to achieve this.

Please guide me on how to achieve this objective

Thanks

Upvotes: 0

Views: 614

Answers (1)

Jean-Michel
Jean-Michel

Reputation: 5946

You can get value like "array[1]" but can't apply tokenize directly on soap:Body with ESB 4.8.1 :

<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="MY_VALUE" expression="//soapenv:Body/myNode"/>
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Element1" expression="fn:tokenize(syn:get-property('MY_VALUE'),'_')[1]"/>

With this message :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <myNode>A_B_C</myNode>
    </soapenv:Body>
</soapenv:Envelope>

property 'Element1' contain : 'A'

Upvotes: 1

Related Questions