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

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

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'

Related

WSO2 Proxy service XML Xpath

Im using wso2 EI 6.5.0
in my proxy service i need to get element between these 2 tags <aa></aa>
xpath //tem:Request is working but /tem:Request/xDoc/aa does not work
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Request>
<xDoc>
<aa>
<bb>
....
</bb>
<cc>
<Parameter>
......
</Parameter>
</cc>
</aa>
</xDoc>
</tem:Request>
</soapenv:Body>
</soapenv:Envelope>
You have to use either /soapenv:Envelope/soapenv:Body/tem:Request/xDoc/aa or $body/tem:Request/xDoc/aa.
The purpose of using "//" in an xpath is to directly access a particular element. But if we use "/", we need to specify the entire path to traverse through the XML tags and reach a particular element.
On a different note, if you want to access the tag <aa/> then you can directly use the xpath //aa.

Salesforce soap error: not a valid value for the enum 'ExecutionLogType'

Can anyone help me with this? I can't find information anywhere about this error message.
I created a webservice class and i'm using SoapUI just to check if it's working and I keep getting the error below.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>'' is not a valid value for the enum 'ExecutionLogType'</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
My input is below. I I don't know how to use the field Client or why it's generated in the wsdl, this field is not in my class.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:exec="http://soap.sforce.com/schemas/class/ExecutiveCareWebservice">
<soapenv:Header>
<exec:AllowFieldTruncationHeader>
<exec:allowFieldTruncation>FALSE</exec:allowFieldTruncation>
</exec:AllowFieldTruncationHeader>
<exec:DebuggingHeader>
<exec:categories>
<exec:category>ALL</exec:category>
<exec:level>DEBUG</exec:level>
</exec:categories>
<exec:debugLevel></exec:debugLevel>
</exec:DebuggingHeader>
<exec:CallOptions>
<exec:client>1</exec:client>
</exec:CallOptions>
<exec:SessionHeader>
<exec:sessionId>00D0E0000008dby!ASAAQBqFFnoPgI88ekHhKy4.N0aKNAw5sIR_1LSGSqzZ_cOg.4oH9hpyW1cB2JDC._BnMKu54FhiJ4p_ORUyIQf39MbRZoqs</exec:sessionId>
</exec:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<exec:getActiveClientes>
<exec:validationDate></exec:validationDate>
</exec:getActiveClientes>
</soapenv:Body>
</soapenv:Envelope>
Thanks in advance!
Joana
Simplify your soapenv:Header headers. I suspect the problem is with the exec:DebuggingHeader header. In particular, the exec:debugLevel is likely related to the ExecutionLogType.
Just leave that header out completely. In fact, the only header you should need is exec:SessionHeader

SoapUI how to check the count of number of items returned in response

is there is way to check the count of the items returned. basically I have a soap service which can return list of data items, is there an easy way to have an assert statement to check the count of the list? tried groovy script but didn't have much luck
You can add and assertion of XPath Match type in your testStep, and there check the condition. i.e you have a response similar to:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<myRoot xmlns:nt="http://mynamespace/">
<list>
<element>data1</element>
<element>data2</element>
<element>data3</element>
</list>
</myRoot>
</soapenv:Body>
</soapenv:Envelope>
Then add in your assertion the next XPath count(//*:myRoot/*:list/*:element) and set the expected result, in this case 3:
Hope this helps,
Yes. You can create a XPath Match assertion. Use the count() function.
There is a website that is a nice reference for all the XPath functions: http://zvon.org/comp/r/ref-XPath_2.html#Functions~count

need to replace < symbol with &lt from an xml at particular node using xslt

INPUT
"hi all i need an xslt to replace < symbol to &lt: in the particular node of an xml, how can i achieve this."
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adm="http://axn/someurl/">
<soapenv:Header/>
<soapenv:Body>
<adm:Access>
<String1> <log item='value' price='fixed'/></String1>
<String2><US/></String2>
</adm:Access>
</soapenv:Body>
</soapenv:Envelope>
OUTPUT
"this is wat finally i need. replcing < with < at node0 and node1.i need to replace only "<" but not ">" symbol"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axn="http://axn/someurl/">
<soapenv:Header/>
<soapenv:Body>
<axn:Access>
<node0><log item='value' price="fixed" /></node0>
<node1><US /></node1>
</axn:Access>
</soapenv:Body>
</soapenv:Envelope>
"have tried to parse the content of node0 and node1 as text with and replace but it dint work"
It is not possible, using XSLT, to replace the < symbol. XSLT provides access to the values inside markup (e.g. element names) and to the markup payload - not to the markup itself (other than by way of copy).
What you can do is output some text using the above values - see for example:
Converting XML to escaped text in XSLT
How do I Emit Escaped XML representation of a Node in my XSLT's HTML Output

How to change the way coldfusion send the soap response?

I have a coldfusion webservice which takes in XML data and send back the acknowledgement.
When there is an error the current code returns me the soap response as
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:updatePendingTicketsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://v02.intouchdataservice">
<updatePendingTicketsReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><![CDATA[<fault>
<faultcode>TO BE DEFINED IF NEEDED</faultcode>
<faultstring >Content is not allowed in prolog.</faultstring>
<faultactor>InTouch</faultactor>
</fault>]]></updatePendingTicketsReturn>
</ns1:updatePendingTicketsResponse>
</soapenv:Body>
</soapenv:Envelope>
But what I would like to have in response is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>TO BE DEFINED IF NEEDED</faultcode>
<faultstring >Content is not allowed in prolog.</faultstring>
<faultactor>InTouch</faultactor>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Is there a way we can change the way coldfusion sends back the response when there is an exception?
In addition to that, Is there a way we can add an XML schema to the coldfusion WSDL to validate the XML document thats been send ?
Thank you
I think no but you can put whole code in try and catch define your own response code.
You can use the wsdlfile attribute of <cfcomponent /> to specify a custom WSDL.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7e0e.html
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-78a6.html