Maximo

 View Only
  • 1.  Convert enterprise service work order sync response from xml to json

    Posted Thu July 14, 2022 02:35 AM
    Edited by System Tue August 22, 2023 04:43 PM
    Hi

    I have written  automation script for external exit for enterprise service to convert the external json and convert it to maximo workorder object and save it. This script is working fine and I am getting the response for work order creation in below xml format.

    <?xml version="1.0" encoding="UTF-8"?>
    <SyncMXWOResponse xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2022-07-13T05:44:13+00:00" transLanguage="EN" baseLanguage="EN" messageID="6376916576910527103497">
    <MXWOSet>
    <WORKORDER>
    <SITEID>BEDFORD</SITEID>
    <WONUM>W0959187</WONUM>
    <WORKORDERID>133343</WORKORDERID>
    </WORKORDER>
    </MXWOSet>
    </SyncMXWOResponse>

    Now I am writing automation script for response of enterprise service where I need to convert the above xml structure to below json structure and the same should be returned to the caller of the enterprise service endpoint as response.
    {
        "wonum": "W0959187",
        "status": "success"
    }

    Any sample code or example to achieve this in enterprise service response. I am trying to create a json structure object in the script and converting xml to json but it is not allowing to do so.

    Regards
    Abhinav





    ------------------------------
    Abhinav Srivastava
    ------------------------------


    #AssetandFacilitiesManagement
    #MaximoIntegrationandScripting
    #Maximo


  • 2.  RE: Convert enterprise service work order sync response from xml to json

    Posted Thu July 14, 2022 03:05 AM

    Hi, 
    Did you try the JSON Mapping? It can be used for enterprise service to convert Json to XML for the post message and convert the XML to Json format for the response.

    https://www.ibm.com/support/pages/maximo-json-mapping-looking-example



    ------------------------------
    Thi Minh Man Nguyen
    ------------------------------



  • 3.  RE: Convert enterprise service work order sync response from xml to json

    Posted Thu July 14, 2022 06:47 AM
    Thanks, it works with JSON mapping.

    ------------------------------
    Abhinav
    ------------------------------



  • 4.  RE: Convert enterprise service work order sync response from xml to json

    Posted Wed July 20, 2022 07:21 AM
    Hi, 

    I noticed that after using JSON mapping in the enterprise service response it looks to be converted from xml to JSON but the in the response header for enterprise service it is still of type text.  I am sending the request as content type:application/json and expect the same type in response header but I get text/plain type. The data looks like text


    Below is enterprise service configuration:-


    I am using external automation script for request data transformation for work order and response is of type JSON Mapper exit in the processing class.

    ------------------------------
    Abhinav Srivastava
    ------------------------------



  • 5.  RE: Convert enterprise service work order sync response from xml to json

    Posted Thu July 21, 2022 12:51 AM
    Hi,
    Actually, I am aware of JSON mapping, I haven't used it. I think the response should be in Content-Type : Application/Json or maybe there is a property to set that.
    Anyway, You are creating the API for the external system to call like a rest API, right? Why don't you use the Maximo Rest API? You can build the payload with the object Struture. Maximo will handle the response. You can limit the field in response payload by adding the header properties. 
    The API would be like this. 
    https://{localhost}/maximo/oslc/os/MXWO/?lean=1
    Maximo_NextGen_REST_API_-_nextgen.pdf

    ------------------------------
    Thi Minh Man Nguyen
    ------------------------------