Executing the rest.extendedJSONConversion Sample
The
rest.extendedJSONConversion
sample includes:
- REST SOA projects (
/rest-soa-projects/
):restbt.sample.extended.json.conversion/Composites/restbt.sample.extended.json.conversion.composite
(restbt.sample.extended.json.conversion/DeploymentArtifacts/restbt.sample.extended.json.conversion.daa
):REST-Java
(Provider) andREST-Java-REST
(Client) components to demonstrate the enhancementscom.sample.restbt.sample.extended.json.conversion
: Provider and Client Java Implementations
- SoapUI projects to invoke the REST Apps (
/SoapUI-projects/REST-ExtendedJSONConversion-soapui-project.xml
):- Service “
InvokeRESTProvider
”: SOAPUI project to send a REST request to the REST Provider (REST-Java
) - Service “
InvokeRESTClient
”: SOAPUI project to send a REST request to the REST Client (REST-Java-REST
) which in turns sends a REST request to the REST Provider (REST-Java
)
- Service “
httpConnector
”) are deployed on
localhost:9897
.
Provider side (Service/Outbound/Response): XML-to-JSON Conversion of String XSD Element
Consider an XSD element that is defined as a “string” in the Provider-side WSDL Schema (identified by the "type" attribute, which must be set to XSD string, for example 'type="xsd:string"' where "xsd" points to the XML Namespace "http://www.w3.org/2001/XMLSchema
").
If the XML Response contains a non-numeric string as the value for that XSD element (for example "teststring" or "test1234"), the JSON Response object is serialized correctly as part of the standard XML-to-JSON Conversion that is as a JSON String ("teststring" or "test1234”).
However, if the XML response contains a purely numeric String as the value for that XSD element (for example "1234"), then the standard XML-to-JSON Conversion converts the element to a JSON Number (for example 1234 as opposed to "1234" that is not a JSON string), which would result in an inconsistent conversion.
This holds true for other JSON types as well, for example, Double, Boolean, and so on. With this release, the XSD Element's (in the sample scenario, the “Value” element in Sample.wsdl
) "type" attribute is factored into the XML-to-JSON Conversion specifically for JSON Strings that is if the XSD Element is of type "string", the resultant JSON Object is a JSON String as well and not a JSON Number.
This affects the service-side RESPONSE. The REQUEST is not affected.
Client side (Reference/Inbound/Request): XML-to-JSON Conversion of String XSD Element
Whether an element is of type “string” is inferred from the Reference-side REST Resource Configuration (RRC) file, specifically from the “Request” of the “POST” method.
In the sample scenario that would be the “Request” of the “addOperation”. If you indicate via the RRC file that “Value” is a string (by use of ‘”Value”:”123”’), then with this release, the POST Request generation honors the “string” type by sending a JSON string, even if the “Value” contains only a purely numeric value.
This affects the POST method’s REQUEST. The POST method’s RESPONSE is not affected.
This behavior is demonstrated in the “Test Scenario” section below.