2 Replies Latest reply on Oct 22, 2020 11:08 AM by Luc Clement

    How to parse rest service response (payload json)

    Claus Peter New Member

      hi all

       

      I am working on rest service integration in an ActiveVOS BPEL flow. So far we get the response of the service. It looks like that:

       

      <rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"

                         statusCode="200">

         <rest:headers>

            <rest:header name="x-corr-id" value="972631e2-0a31-11eb-91e4-4ead98d21567"/>

            <rest:header name="Strict-Transport-Security" value="max-age=15724800;includeSubDomains"/>

            <rest:header name="Content-Security-Policy" value="default-src 'self'"/>

            <rest:header name="Connection" value="keep-alive"/>

            <rest:header name="X-Content-Security-Policy" value="default-src 'self'"/>

            <rest:header name="Content-Length" value="208"/>

            <rest:header name="Date" value="Fri,09 Oct 2020 13:16:07 GMT"/>

            <rest:header name="Content-Type" value="application/json"/>

            <rest:header name="X-WebKit-CSP" value="default-src 'self'"/>

         </rest:headers>

         <rest:payload contentType="application/json">{"messages":[],"vnkeyResult":{"contractID":"06166159",

         "modified":"2000-07-16T22:00:00.000+0000","userId":"P91605  ","vnKey":"347034247001"}}</rest:payload>                                                

      </rest:RESTResponse>

       

      Now I should parse the Json string (part of the payload) for the value of the attribute "vnKey".

      Could anybody give me some support for this requirement. Is there any string function or method to provide this ?

      At the end I like to have maybe a variable like VNKEY = 347034247001.

       

      regards

      Claus

        • 1. Re: How to parse rest service response (payload json)
          Gaurav Singh Active Member

          Having dealt with a lot of JSONs in AVOS I have following experience:

           

          • AVOS is very poor when it comes to JSON handling.
          • You need to convert the JSON to XML to work with these JSONs. You can use pre-built AVOS functions or can write your own Java interface in AVOS to do that.
          • Pre-built AVOS function to convert JSON to XML  and XML to JSON has few known issues. So if you have few simple operations then go with pre-built function else write your own Java interface.
          • abx:jsonToXml($myJson) is function to convert JSON to XML (where $myJson is your payload).
          • abx:xmlToJson($myXml) is function to convert XML to JSON (where $myXml is you XML you want to convert to JSON)

           

          Thanks

          Gaurav Singh

          mail-to: gausin3@gmail.com

          • 2. Re: How to parse rest service response (payload json)
            Luc Clement Support Moderators

            The ActiveVOS distribution of Process Server makes it possible to interwork with JSON but hasn't been evolved to handle integration use cases.

             

            The Cloud Application Service's Process Server has been evolved and specifically designed to handle application integration, eventing and data APIs use cases. You'll find that working with JSON and XML is simple. Have a look at the overviews here: Cloud Application Integration.