IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

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

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

    Posted Thu June 16, 2016 02:35 PM

    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


    #webMethods
    #soa
    #API-Management


  • 2.  RE: Body of post rest request not visible when Content-Type is application/xml

    Posted Thu June 16, 2016 07:19 PM

    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).


    #soa
    #API-Management
    #webMethods


  • 3.  RE: Body of post rest request not visible when Content-Type is application/xml

    Posted Sun June 19, 2016 04:46 PM

    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?


    #webMethods
    #soa
    #API-Management


  • 4.  RE: Body of post rest request not visible when Content-Type is application/xml

    Posted Mon June 20, 2016 04:02 PM

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


    #API-Management
    #soa
    #webMethods


  • 5.  RE: Body of post rest request not visible when Content-Type is application/xml

    Posted Mon June 20, 2016 04:19 PM

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


    #webMethods
    #soa
    #API-Management