AssignMessage policy seems to change response encoding

Not applicable

I'm stuck on a weird issue. I've got a SOAP webservice that I wan't to proxy as a REST service. The complicating factor is that this SOAP service returns a multipart message that contains a SOAP response and a PDF attachment. So my goal is to embed the PDF, base64 encoded, in the SOAP response part and then have that go through the normal XML to JSON translation that Apigee offers.

My first attempt, in which I used a JS policy to rework the response into an XML that contained the PDF attachment as a tag with base64 encoded content was mostly successful except that when I decoded the PDF the result wasn't the PDF I expected but an empty one. After asking a question on the forum I was pointed in the direction of a node or java based callout as the JS policy treats everything as a string which has a negative effect on the encoding it seems.

So today I worked on setting up a new proxy that used this new approach. I started by firstly making a node proxy that takes the SOAP response, that I captured via SoapUI, and returns a base64 encoded response. When I decoded this response I got the PDF I expected. I then created a new REST -> SOAP -> REST proxy and inserted an assignmessage step (which takes the SOAP response and sets it as the request (input)) followed by a callout to this node proxy as the first steps in the response flow. This works as in it returns a valid REST response, but when I again decoded the PDF it again was invalid.

So to me it looks like the assignmessage does something to the response. to test this I made a straight SOAP proxy. When I tested this and took the PDF part of the multipart response that PDF was what I expected. I then changed to proxy so that in the response flow I use 1 assignmessage to take the response and put it into a variable and then a 2nd to assign this variable as the new response. Visually these response look the same in Postman, but when I now take the PDF part from the response it is invalid again?

What am I doing wrong? Why is the response content or its encoding changing when using the assignmessage policy? Is there any way to work with the response without this effect happening? (the only option left for this kind of approach seems to be a Java callout for which I found an actual example in the forum, but which I can't test until I get a full account).

0 0 221
0 REPLIES 0