Hi,
I am trying to extract a value from a soap message i.e ACCOUNT_NUMBER from the following soap message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://xx.yyyy.com/xxxxx"> <soapenv:Header/> <soapenv:Body> <ser:CreditRequest> <ACCOUNT_NUMBER>5057</ACCOUNT_NUMBER> </ser:CreditRequest> </soapenv:Body> </soapenv:Envelope>
When I used Extract Variables policy, I’m not getting the value extracted. Here's the policy:
<ExtractVariables name="Extract-CustomerAccNo"> <DisplayName>Extract AccNo</DisplayName> <Properties/> <Source clearPayload="false">request</Source> <XMLPayload stopPayloadProcessing="false"> <Namespaces> <Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/envelope/</Namespace> <Namespace prefix="ser">http://xx.yyyy.com/xxxxx</Namespace> </Namespaces> <Variable type="string" name="req.accno"> <XPath>/soapenv:Envelope/soapenv:Body/ser:CreditRequest/ACCOUNT_NUMBER</XPath> </Variable> </XMLPayload> </ExtractVariables>
due to some namespace issue maybe? There is no default namespace available in the soap request. Otherwise I could have tried the following:
<XPath>/soapenv:Envelope/soapenv:Body/ser:CreditRequest/xmlns:ACCOUNT_NUMBER</XPath>
Could you please help me to get the value extracted?
Solved! Go to Solution.
Hi @Julie Joseph,
I used the same above code and same input and able to see apigee is extracting the account number value irrespective of default name space. In the header I gave content-type as application/xml. Rest all I gave same. Attaching the screen shot for your reference. When I dont give content-type as application/xml it does not work. Hope it helps.
Hi @Julie Joseph,
I used the same above code and same input and able to see apigee is extracting the account number value irrespective of default name space. In the header I gave content-type as application/xml. Rest all I gave same. Attaching the screen shot for your reference. When I dont give content-type as application/xml it does not work. Hope it helps.
Thanks Veera. It is working for me now, when I provided content-type.
@docs , Can we highlight this in xml example , In Extract Variables Policy as a note ? Thank you
@Anil Sagar / @Veera Balaji Penugonda - Do you mean setting the header in the original SOAP message, or extracting it from the header after the SOAP-to-REST policy, like below?
<Header name="Content-Type"> <Pattern ignoreCase="false">{request.header.Content-Type}</Pattern>
</Header>
@Floyd Jones , Setting the header in the API Request that will be sent to the edge.
Thanks, @Anil Sagar. Much appreciated. I added a note to the Extract Variables XML example saying that extraction works only if the content type is set in the message header (including SOAP). If you think this is SOAP-specific, please let me know.
Cool, Thank you @Floyd Jones , Looks great.
I am doing exactly the same thing and also setting the content-type but still not able to extract the value from soap enevlope.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |