Wednesday, December 21, 2011

Difference in Retrieving value from OSB body variable and other OSB variable

As I am new to the OSB , I got stuck with this problem while developing an interface in my current project. My objective was to capture a unique ID from incoming SOAP request message. My SOAP request message is as follows

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://siebel.com/CustomUI" xmlns:ahs=http://www.siebel.com/xml/SampleUpDispSt> <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <cus:SampleUpDispStInput xmlns:cus="http://siebel.com/CustomUI" > <ahs:ListOfSampleUpDispSt xmlns:ahs="http://www.siebel.com/xml/SampleUpDispSt"> <ahs:Action> <!--Optional:--> <ahs:ProjId>1-2N94XX</ahs:ProjId> <ahs:CompletedDate>12/07/2011</ahs:CompletedDate> <ahs:Status>Assigned</ahs:Status> </ahs:Action> </ahs:ListOfSampleUpDispSt > </cus:SampleUpDispStInput> </soapenv:Body> </soapenv:Envelope>

My Objective is to capture the ProjId value from the SOAP message. So I have created a variable to capture the <soapenv:Body> value and using an assign activity I have captured the entire body value in that variable. My Assignment statement xpath is “$body” and I have used a variable named “varResponseBody” .

image 

I was surprised at next step when while trying to capture the <ahs:ProjId> value from $varResponseBody using an Assign activity. The Xpath was given as “$varResponseBody/cus:SampleUpDispStInput/ahs:ListOfSampleUpDispSt/ahs:Action/ahs:ProjId/text()”. Because my understanding was as I have copied the “body” variable in “varResponseBody” it would have everything as the body variable has, which was correct because as per our testing in OSB console to print the “varResponseBody” it gives us below output.

image

But I was unaware of the fact that the difference lies in the context of $body and $varResponseBody . Please find below snapshot.

image

 

image

So If we are trying to capture ProjId value based on $body then the xpath will be “$body/cus:SampleUpDispStInput/ahs:ListOfSampleUpDispSt/ahs:Action/ahs:ProjId/text()” and If we are trying to capture ProjId value based on $varResponseBody then the xpath will be  “$varResponseBody/ahs:ListOfSampleUpDispSt/ahs:Action/ahs:ProjId/text()”