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

To group output from applinx, convert XML to JSON

  • 1.  To group output from applinx, convert XML to JSON

    Posted Wed April 10, 2024 05:28 PM

    I am using applinx 1015 and able to create 1 path procedure in 1 procedure group.
    And using screens I am assigning field mapping, for input and output.
    after assigning all required outputs I am receiving like this

    <tns:test_1_Response xmlns:tns=“http:”>
    <first_name></first_name>
    <last_name></lastt_name>
    <middle_name></middle_name>
    <email_id></email_id>
    <phone_num></phone_num>
    <message_out>updated</message_out>
    <first_name></first_name>
    <last_name></last_name>
    <middle_name></middle_name>
    <email_id></email_id>
    <phone_num></phone_num>
    </tns:test_1Response>

    But this is what i require

    <tns:test_1_Response xmlns:tns=“http:”>
    <person_1>
    <first_name></first_name>
    <last_name></last_name>
    <middle_name></middle_name>
    <email_id></email_id>
    <phone_num></phone_num>
    </person_1>
    <message_out>updated</messsage_out>
    <person_2>
    <first_name></first_name>
    <last_name></lastt_name>
    <middle_name></middle_name>
    <email_id></email_id>
    <phone_num></phone_num>
    </person_2>
    </tns:test_1Response>

    How can i group the output for easy human reading (can i use ‘add structure’ or ‘new data structure’ for it) ?
    How can i change the XML to JSON (I am able to do it with a python/c# code, but would like to do it in applinx)? tried rest-API-config to modify, but couldn’t understand what is need to change to convert XML to JSON
    and what is tns ?


    #Mainframe-Integration
    #ApplinX
    #webMethods


  • 2.  RE: To group output from applinx, convert XML to JSON

    Posted Thu April 11, 2024 03:53 AM

    Hi,

    You can create a path procedure with a data structure (“Person”) as the output, then map values into the data structure and expose the procedure as REST API that would return the output as a JSON file, without the need to convert from XML to JSON.

    Regards,
    Gadi


    #webMethods
    #Mainframe-Integration
    #ApplinX


  • 3.  RE: To group output from applinx, convert XML to JSON

    Posted Thu April 11, 2024 10:15 AM

    Hello Gadi,
    Thanks for the reply.

    I am able to solve one issue, I am now getting response the way I want, able to group output using data structure.

    But I am unable to find the option where the REST API response is JSON, I have created a new Path Procedure and procedure group and copy REST URL to clipboard and check to see output in XML only.
    I kind of did the same steps again but could not see a difference that gets response in JSON.

    Please note that I am using Microsoft Edge to check the REST API output

    Can you please point me to the place where I can see the option, that makes difference in REST API response from XML to JSON.

    How to expose procedure as REST API that can return the output as JSON ?

    I am able to expose procedure as rest API that can return the output as XML.


    #webMethods
    #Mainframe-Integration
    #ApplinX