The XML-to-JSON policy

The XML-to-JSON policy converts a request or response body from XML to JSON. The syntax of the policy is as follows:

The kind attribute takes two values:

  • javascript-friendly: The converted JSON has a form friendly to JavaScript developers
  • direct: The converted JSON reflects the original XML document's structure

The apply attribute takes two values:

  • always: This always converts the XML request to JSON
  •  content-type-xml: This converts the XML request only if the Content-Type header indicates the presence of XML

The consider-accept-header attribute takes two values:

  • true: This applies conversion if XML is requested in the request accept header
  • false: This always applies conversion

In our scenario, we did not use an XML-to-JSON policy as the web service returned a SOAP message and we should not be converting SOAP header XML elements into JSON. However, for demonstration purposes, I removed the logic and replaced the outbound policy with the following code:

When you test the GetProducts API method, we will get a response message as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.67.54