Body of post rest request not visible when Content-Type is application/xml

Hi,

I have a rest resource with a post method and need to both support json and xml. Everything works fine when the ‘Content-Type’-header is ‘application/json’ or ‘text/xml’ but I need to support ‘application/xml’ too. When the header is set to ‘application/xml’ I can’t access the content(body) of the request.

To get the content when the Content-Type header is set to ‘text/xml’ I need to add a object called ‘node’ and convert that to a document. I think I need to a similar trick to get ‘application/xml’ working, I just don’t know what.

Does anybody know how to solve this issue?

Thanks in advance,
Freyr Gudnason

check if your pipeline contain a object of java.io.SequenceInputStream with name “stream”.

you can do this by saving the pipeline with pub.flow:savePipeline

(don’t use pub.flow:savePipelineToFile, it won’t save stream).

if you do, you can convert it to string, then see how to handle it (it may be a MIME, not just xml you expected).

This doesn’t seem to work, when I restorePipeline after saving it there is only one variable named “contentStream” and it’s content is: “com.wm.net.HttpInputStream”.
Do you know what I can do to get this working?

Call the WmPublic service pub.io:streamToString and pass it the contentStream variable.

That worked. Thank you both for your help :smiley: