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
Expand all | Collapse all

How move JSON File to IS Server

  • 1.  How move JSON File to IS Server

    Posted 05/02/18 11:41 AM

    Hello,
    After an HTTP GET request (pub.client:http), I retrieve a JSON file in a documentType.
    I would like to save my JSON file on the server before turning it into a String. How to do ?
    Thanks


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: How move JSON File to IS Server

    Posted 05/02/18 01:51 PM

    I believe you cannot save the IData unless you have converted the json document to string during run-time scenario.

    Also check by the getTransportInfo flow how is it being received from the source.

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #edi


  • 3.  RE: How move JSON File to IS Server

    Posted 05/04/18 06:56 AM

    Thanks for your answer but I would just move the received JSON file to the server before transforming it. Just to see what’s in the JSON document
    Is impossible ?


    #edi
    #webMethods
    #Integration-Server-and-ESB


  • 4.  RE: How move JSON File to IS Server

    Posted 05/04/18 01:46 PM

    Yes I believe If you are receiving the jsonString directly then you can write the file to temp location and analyze it.

    HTH,
    RMG


    #webMethods
    #Integration-Server-and-ESB
    #edi


  • 5.  RE: How move JSON File to IS Server

    Posted 05/09/18 11:56 AM

    pub.client:http does not return the body of the response as a document type. It returns it either as a byte array or as an input stream depending on what you set the loadAs variable to. You can do anything you want with that byte array or input stream before converting it to a document type, including writing it to a file. There are services in WmPublic already that will help you with these tasks.

    Percio


    #webMethods
    #edi
    #Integration-Server-and-ESB


  • 6.  RE: How move JSON File to IS Server

    Posted 05/09/18 12:44 PM

    Hi Sabine,

    Hope the above solutions will work for you!

    HTH,
    RMG


    #edi
    #webMethods
    #Integration-Server-and-ESB


  • 7.  RE: How move JSON File to IS Server

    Posted 05/14/18 06:02 AM

    Thanks

    In webMethods, I use the following services:

    • pub.client: http with:
      . the GET method (IN)
      . loadAs = stream (IN)
      . header Authorization (Basic Token) and Content_type (application / json; charset = utf-8) (IN)
      . body in body (OUT)

    • pub.json: jsonStreamToDocument with:
      . body in jsonStream (IN)
      . document in agriJsonDT (OUT) (my document type)

    • pub.json: documentToJSONString with:
      . agriJsonDT in document (IN)
      . prettyPrint (True) (IN)
      . jsonString dasn jsonString (OUT)
      . agrisJsonName (OUT) (my Path and filename .xml)

    • pub.file: stringToFile with:
      . jsonString in data (IN)
      . agriJsonName in fileName (IN)
      . append (true) (IN)
      . encoding (auto-detect) (IN)

    It’s Ok, I have an .xml file out but it’s not the Json. It’s transformed. I can not take this xml document and put it back in my stream if I have an error.
    Do you have an idea to recover the JSON without transformation


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: How move JSON File to IS Server

    Posted 05/14/18 11:21 PM

    Instead of calling pub.json:jsonStreamToDocument, you could first call pub.file:streamToFile. This would write the raw content to a file. If the JSON document you’re getting is not large (or if you don’t expect the number of concurrent instances of this service to be large), you could even call pub.client:http with loadAs set to bytes instead of stream. This would prevent the need for resetting the input stream, or the need to read the contents from the file that you just wrote, in order to get the document (IData) you need for mapping.

    If you use the bytes approach, you could:

    (1) Call pub.file:bytesToFile to write the contents to a file
    (2) Then call pub.string:bytesToString to convert the bytes to a string (alternatively, you could call pub.io:bytesToStream)
    (3) Finally, call pub.json:jsonStringToDocument to get the JSON document (alternatively, if you called bytesToStream in #2, you could call jsonStreamToDocument in this step)

    Hope this helps,
    Percio


    #webMethods
    #edi
    #Integration-Server-and-ESB


  • 9.  RE: How move JSON File to IS Server

    Posted 05/15/18 03:19 PM

    Hi Sabine,

    If you try use the Percio’s approach it can capture the raw content of the json string (non-transformed) to document structure (IDATA).

    HTH,
    RMG


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 10.  RE: How move JSON File to IS Server

    Posted 05/16/18 04:42 AM

    Hello
    Thank you for your answers.
    After the pub.client:http invoke, I tried to use the pub.file:streamToFile invoke with:
    . fileName (path and filename in variable) (IN)
    . body/stream in stream (IN)
    . append (True) (IN)
    to send json file to the server.

    And then pub.json:jsonStreamToDocument

    But I have an error “Parameter [JsonStream] is not of type: [InputStream]”

    I try again today with the bytes version and I tell you how it happened
    Thanks again


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 11.  RE: How move JSON File to IS Server

    Posted 05/16/18 10:33 AM

    Sorry, the expected result is not the one I was hoping for.
    When I save the JSON from debug mode via “Save IDATA to local file” I get a file that I can use to run tests and restart my flow. It is this file that I would like to recover but without going through the debug mode.
    I attach an excerpt from this file (20180516 - agriJsonDT_extrait.xml)
    File result with bytes or stream is in 20180516_123000_pro_cts_extrait.xml
    Thank you for your help
    20180516_123000_pro_cts_extrait.xml (1.13 KB)
    20180516 - agriJsonDT_extrait.xml (2.51 KB)


    #edi
    #webMethods
    #Integration-Server-and-ESB


  • 12.  RE: How move JSON File to IS Server

    Posted 05/16/18 11:54 AM

    Ah… that is indeed a very different request. What you want is pub.flow:savePipelineToFile. Try that.

    Percio


    #webMethods
    #edi
    #Integration-Server-and-ESB


  • 13.  RE: How move JSON File to IS Server

    Posted 05/16/18 12:05 PM

    That’s exactly what I wanted.
    Thank you very much and have a good day


    #Integration-Server-and-ESB
    #edi
    #webMethods


  • 14.  RE: How move JSON File to IS Server

    Posted 05/16/18 03:14 PM

    Did you set loadAs=stream and the receiving service input is set as *contentStream or jsonString??

    OK plz try with bytes and let us know.

    HTH,
    RMG


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 15.  RE: How move JSON File to IS Server

    Posted 05/17/18 04:41 AM

    My new flow is:

    • pub.client:http with:
      . the GET method (IN)
      . loadAs = stream (IN)
      . headers=> Authorization (Basic Token) and Content_type (application / json; charset = utf-8 (IN)
      . header in header (OUT)
      . body in body (OUT)

    • pub.json:jsonStreamToDocument with:
      . body/stream in jsonStream (IN)
      . document in agriJsonDT (OUT) (my document type, document reference $rootArray)

    • pub.flow:savePipelineToFile with:
      . variable agriJsonName (mypath and filename .xml) in filename (IN)

    And the result is what I wanted, an XML file that I can reuse.

    Then I loop on the agriJsonDT to turn all the fields into a string to send it in SAP.
    Do I answer your question?
    Thank you for your help


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 16.  RE: How move JSON File to IS Server

    Posted 05/17/18 12:05 PM

    Sounds good with your new flow!!!

    Cheers!
    RMG


    #Integration-Server-and-ESB
    #webMethods
    #edi