How to extract SOAP response attachment?

Not applicable

Hi, I am getting SOAP body with attachment from my target endpoint. I want to extract only attachment content and pass it client.

Is anyone have example how to process this through APIGEE Edge?

Thanks,

Venu

2 7 3,517
7 REPLIES 7

Not applicable

Hi @Venu.Pujari1,

You can generate a proxy for a WSDL in the UI and follow that pattern. There are some example WSDLs you can choose from when you click on the + API Proxy button.

If you don't want to do that, essentially what those proxies do are to convert the SOAP response to JSON with an XMLtoJSON policy, then extract the body thusly with an ExtractVariables policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="get-response-soap-body">
    <DisplayName>Get Response SOAP Body</DisplayName>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="body">
            <JSONPath>$.Envelope.Body</JSONPath>
        </Variable>
    </JSONPayload>
    <Source>response</Source>
    <VariablePrefix>soapresponse</VariablePrefix>
</ExtractVariables>

Then set the response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="set-response-soap-body">
    <DisplayName>Set Response SOAP Body</DisplayName>
    <Set>
        <Payload contentType="application/json">{soapresponse.body}</Payload>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

Not applicable

@coverbeck

Thanks for your time looking into this issue. As i have mentioned I am getting SOAP response with attachment.The customer wants the SOAP attachment as a SOAP Body the soap body which is existed need to clear before substitution.FYI. I am attaching the SOAP response which was returned from backend.

Thanks,

Venu

Sorry, I had skimmed your original question, and I haven't used SOAP attachments before. Looking at your sample SOAP response, there are 2 XML root elements in the response. I don't know how you can handle that off-hand other than through a JavaScript policy.

Not applicable

@coverbeck

Thanks a lot Coverveck!.

When i use jmeter SOAP/XML-RPC Request to hit the backend server,i am getting the SOAP response as two parts,soap body followed by soap attachment.

Thanks,

Venu

I am sorry I mis spelled your name .

Thanks a lot for your quick response!

Oh, I see, the response is content-type multipart/Related?

I'm guessing you'll have to separate out the parts of the response then in a JavaScript/Java callout/Python policy (Java callout and Python policies are only available in Apigee Edge; I don't know what you are on), and then just use the attachment part in the response.

I haven't actually done this, but it sounds like it should be possible.

@coverbeck

I am trying with javacallout policy,but failing to retrieve the attachment.If you have any reference java/js/py can you please share with me the examples

Thanks,

Venu