CA Service Management

Expand all | Collapse all

SOAP API use JSON

Jump to Best Answer
  • 1.  SOAP API use JSON

    Posted 04-17-2018 11:51 AM

    Can the SDM SOAP API use Json payloads as well as XML payloads? I know that the SDM REST API can use either.



  • 2.  Re: SOAP API use JSON
    Best Answer

    Posted 04-17-2018 05:16 PM

    Hi.
    As far as I'm aware of, the SOAP web service is restricted to accept incoming XML only. And it only produces XML in its responses. This is the nature of any SOAP service.
    The REST service only accepts incoming XML as well, as far as I know, but can produce XML or JSON in its responses
    Regards
    .....Michael



  • 3.  Re: SOAP API use JSON

    Posted 04-17-2018 05:30 PM

    Thanks for the response Michael. I suspected as much but wanted to ask for verification.

    I have verified that the REST API will produce AND accept both XML and Json payloads.

     

    Cheers,

    Lindsay



  • 4.  Re: SOAP API use JSON

    Posted 04-18-2018 05:12 AM

    Hi Lindsay.

     

    In fact I never tried to feed the SDM REST service with Json payload.

    I was convinced, that the ability to send and correctly process Json payload, is based on the implementation on the server side., And because the docs are only working with xml as well as all examples do, I assumed that the REST webservice accepts incoming xml only.

    In the meantime I started some testing with json. Even though I was able to get an access key with json payload, I wasnt able to do a POST to create a record with json.

    Do you have a working example for a POST or PUT request (creating or updating) with a json paylod?

    For example to create a change activity log record you might send a post with the following xml payload:

    <chgalg>
    <type REL_ATTR="LOG"/>
    <change_id REL_ATTR="400108"/>
    <description>Activity Log created from REST API Java Samples code
    </description>
    </chgalg>

    I tried the following json without success

    { "chgalg": {
       "type": { "REL_ATTR":"LOG"},
       "change_id":{"REL_ATTR": 400108},
       "description":"Activity Log created from REST API Java Samples code"
    }
    }

     

     Thanks

    ......Michael



  • 5.  Re: SOAP API use JSON

    Posted 04-18-2018 08:02 PM

    Hi Michael,

     

    Works for me. Does your POST have a Header Key "Content-Type" with a Value of "application/json; charset=UTF-8"?

     

    I also have a Header Key "Accept" with Value "application/json" so that it returns Json instead of XML.

     

    The environment I'm using is r17.1.

     

    Cheers,

    Lindsay



  • 6.  Re: SOAP API use JSON

    Posted 04-20-2018 07:42 AM

    Hi Lindsay.

    Thanks for the feedback and your confirmation.

    Yes , I specified these headers as well, but was using 17.0.

    Best regards

    ..............Michael



  • 7.  Re: SOAP API use JSON

    Posted 04-20-2018 01:10 PM

    I don't have a r17.0 environment but I tried it against a r14.1 environment and the Json payload worked there as well.



  • 8.  Re: SOAP API use JSON

    Posted 04-20-2018 01:14 PM

    Ah, I see it now. You are missing the @ before REL_ATTR



  • 9.  Re: SOAP API use JSON

    Posted 04-23-2018 05:44 AM

    Lindsay, you are the best !

    Thanks a lot for this hint.

    I wasn't aware that xml tag attributes must be mapped with a preceeding @ character in json, at least in the sdm rest service, even though I just recognized that this is the case in json responses from the sdm rest service as well.

     

    I wasn't able to find a general/official rule set how xml must be mapped to json. And I assume this is service implementation dependent. So in our case (SDM) the @ sign seems to be the solution.

    Thanks again for your help in this?

    Best regards

    ..........Michael



  • 10.  Re: SOAP API use JSON

    Broadcom Employee
    Posted 04-17-2018 05:35 PM

    I don't know much of it but simply throw some expert's input here

    java - Why not SOAP with JSON? - Stack Overflow 

    according to this discussion, REST can consume both XML and JSON.