webMethods

webMethods

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.

 View Only
Expand all | Collapse all

How to get RESTful POST/PUT request body(payload) in webMethods?

  • 1.  How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Tue August 05, 2014 03:08 AM

    In GET(_get) service,I can get input params from $resourceID and $path ,but in POST/GET,I can not find a variable in WM,anyone can give me some suggestion, many thanks!
    PS:WM version is 8.2.


    #webmethods-Protocol-and-Transport
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Tue August 05, 2014 10:41 AM

    After one day’s trial,I figure out this issue :x

    Correct steps as follows:
    1.fill http request body with varableName=+json string,eg:bookInfo={…},although very strange,but it works.,
    2.encode the string generate in step 1
    3.select an encode,eg:utf=8
    4.in WM flow,set input as bookInfo~


    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport
    #webMethods


  • 3.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Tue August 05, 2014 12:13 PM

    OK thanks for the updating back on this thread.

    Sorry for no helping hands.

    HTH,
    RMG


    #webmethods-Protocol-and-Transport
    #webMethods
    #Integration-Server-and-ESB


  • 4.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Tue December 02, 2014 03:24 PM

    I successfully get body variables without setting input variable when using POST and PUT.
    But it doesn’t work for DELETE and GET even when variables are in input.

    Yee Fong, do you get body variables with POST and GET or only with POST?


    #Integration-Server-and-ESB
    #webMethods
    #webmethods-Protocol-and-Transport


  • 5.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Fri December 05, 2014 05:47 PM

    GET/DELETE should also have body/bytes in the pipeline .

    Is that it not the case?

    HTH,
    RMG


    #webmethods-Protocol-and-Transport
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Tue December 16, 2014 04:14 AM

    Hello,

    No, I use pub.flow:tracePipeline in the REST services to have a look on the pipeline and there is a contentStream only when I use POST & PUT. With the same request but using GET or DELETE I have no contentStream in pipeline.

    When using only _default service with tracePipeline this is the same behaviour.

    I’m on 9.6


    #webmethods-Protocol-and-Transport
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Thu December 18, 2014 05:26 PM

    Can you please try to use the getTransportInfo service and debug the pipeline (ofcourse streams cannot be saved or shown in the pipeline)

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport


  • 8.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Fri December 19, 2014 09:55 AM

    getTransportInfo doesn’t display body content, what do you want to check with it?

    Exemple with POST:
    [1185803]2014-12-19 11:42:51 CET [ISP.0090.0002C] — END tracePipeline —
    [1185802]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 $path {java.lang.String} = ‘1546’
    [1185801]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 $resourceID {java.lang.String} = ‘123’
    [1185800]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 contentStream {com.softwareag.is.enterprisegateway.net.HttpInputStream} = ‘com.softwareag.is.enterprisegateway.net.HttpInputStream@9f31d67’
    [1185799]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 var2 {java.lang.String} = ‘54’
    [1185798]2014-12-19 11:42:51 CET [ISP.0090.0008C] 0 var1 {java.lang.String} = ‘12’
    [1185797]2014-12-19 11:42:51 CET [ISP.0090.0001C] — START tracePipeline [19/12/14 11:42] —

    Exemple with GET:
    [1185810]2014-12-19 14:56:36 CET [ISP.0090.0002C] — END tracePipeline —
    [1185809]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 $path {java.lang.String} = ‘1546’
    [1185808]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 $resourceID {java.lang.String} = ‘123’
    [1185807]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 var2 {java.lang.String} = ‘54’
    [1185806]2014-12-19 14:56:36 CET [ISP.0090.0008C] 0 var1 {java.lang.String} = ‘12’
    [1185805]2014-12-19 14:56:36 CET [ISP.0090.0001C] — START tracePipeline [19/12/14 14:56] —

    In attachments 2 screenshots of request and response



    #webMethods
    #webmethods-Protocol-and-Transport
    #Integration-Server-and-ESB


  • 9.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Mon March 21, 2016 06:25 PM

    Perhaps my method would be useful for someone.
    I have wM version 9.9, but I suppose it may works in some early version.
    So, let’s look at the types of queries in order…

    1. GET
      This is very simple case without any difficulties.
      1.1) Request
      Use URL to send Resource ID into wM service. E.g. use http://localhost:5555/rest/restSvc/client/123 to request information about Client number 123.
      1.2) Processing
      You may use Java or Flow services.
      You may use separated handlers GET\POST\etc. or DEFAULT handler. In the last case use pub.flow:getTransportInfo to define a request type (get\post\etc.).
      1.3) Response
      Set response code by means of pub.flow:setResponseCode.
      Convert your Document (Document Type) to JSON String thru pub.json:documentToJSONString.
      Set response thru pub.flow:setResponse.
    2. DELETE
      This case is similar previous, but usually the response consists of header only.
    3. POST
      3.1) Request
      Set Content-Type: application/json.
      Set data in json format, e.g.
      {
      “client”: {
      “id”: “123”,…}
      }
      Call your REST service http://localhost:5555/rest/restSvc/client/123
      3.2) Processing
      Unfortunately, you can take json data without any tricks from Java service only. E.g. use code
      IDataMap idm = new IDataMap(pipeline);
      IData customer = idm.getAsIData(“client”);
      But previously add into Java service pipeline variable “client” type of interesting Document Type.
      3.3) Response
      Set response code by means of pub.flow:setResponseCode.
    4. PUT
      This case is similar previous.

    P.S. Useful site to validate JSON https://jsonformatter.curiousconcept.com/


    #webmethods-Protocol-and-Transport
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: How to get RESTful POST/PUT request body(payload) in webMethods?

    Posted Fri September 23, 2016 01:43 PM

    My GET rest service is not populating $resourceID and $path. When I log these values, it shows null. Please help.


    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport
    #webMethods