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
  • 1.  Convert Response from SOAP XML to JSON

    Posted Sun September 10, 2023 04:28 AM

    I have a soap API with Rest Transformation.
    when I call the API as json the request is sent as JSON but the response is returned as XML.
    how to convert the XML to Json using response transformation policy just when the request is json?


    #API-Management
    #webMethods-io-Integration
    #webMethods-cloud
    #API-Gateway
    #webMethods


  • 2.  RE: Convert Response from SOAP XML to JSON

    Posted Mon September 11, 2023 02:58 AM

    hi @mahmoud_elarabi,
    We can write xslt in response transformation policy to achieve same.
    You can refer below link for it

    Regards
    Vikash Sharma


    #API-Management
    #webMethods-cloud
    #webMethods-io-Integration
    #API-Gateway
    #webMethods


  • 3.  RE: Convert Response from SOAP XML to JSON

    Posted Mon September 11, 2023 10:39 AM

    Proceed with caution. There are representations in XML that cannot be accurately converted to JSON without additional definition such as an XSD. E.g. In XML, an array of elements is obvious when there are >1 entries in the list. But if there is just 1 entry, it cannot be determined from the XML alone that the single element should be placed in an array.

    Avoid this if possible. Depending upon the data what you may face is “this mostly works but then occasionally it returns ‘bad’ data” because an element that should be in [ ] is not.

    Check with the API to see if honors the Accept header and have the caller specify Accept: application/json so that the API itself returns JSON and your components do not need to translate.

    Edit: If you’re using API GW, it has it’s own translation facility (with same caveat as above). No need to introduce another component.

    Edit2: Might find the info in this thread WM API Gateway - Request Transformation Payload - From JSON to XML? helpful.


    #webMethods-io-Integration
    #webMethods
    #API-Management
    #webMethods-cloud
    #API-Gateway