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.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  restv2 web output / how to

    Posted 04/20/18 07:07 AM

    Hello,

    I’ve created a rest v2 resource that points to my service and has access only to the GET method.

    When I call the rest service in the browser ( http://ishost:5555/restv2/myservice/ ) i get the details that the service should output, but is using the IS html in the background. ( imagine that you go into IS > packages > package service > run service with / without inputs… is the same style of output )

    What do I have to do to make the output xml / json ?

    I can’t find anywhere in the documentation how to control this, please let me know if this should be posted in a different section.

    Capture.PNG


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: restv2 web output / how to

    Posted 04/20/18 08:16 PM

    I think you have to specify the “Accept” header in your HTTP request to indicate which response format you wish. Since, if you call the service via browser, the desired response type is HTML, the IS generates it. Try curl to issue the requests.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: restv2 web output / how to

    Posted 04/21/18 01:30 AM

    Maybe you can give a try using pub.flow:setResponse2


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 4.  RE: restv2 web output / how to

    Posted 04/21/18 10:02 PM

    That’s also possible, and I’ve used this myself. The drawback of this solution is that the format of the response is fixed and can’t be set by the caller. This can be improved by introducing a service input parameter that would tell in which format the response should be delivered (this value would be used in the call to setResponse2). But adding this parameter would spoil the service interface. Hence I prefer, if calling the service via HTTP, to tell the desired format via HTTP header.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 5.  RE: restv2 web output / how to

    Posted 04/23/18 06:18 AM

    Hello,

    Thank you both for the explanation and guidelines.
    Using curl I can see the output as json.
    All I had to do is to use the “Content-type” and the “Accept” in the header request.

    I’m adding a url to an example if anyone else will need more details in the future:


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services