Forum Discussion

turman's avatar
turman
Occasional Contributor
10 years ago

Conversion from JSON to XML

Hi,

I'm using SoapUI 5.0 to do some non regression tests on REST/JSON services.

SoapUI can convert automatically JSON responses into XML responses. With that functionaly, I can perform some "XPath match" assertions on JSON response, that's great !

It works pretty well on my project but for an unknown reason, I have one service whose JSON response is not converted into XML :

The JSON is :
{
"data": [
{
"id": 1,
"name": "Gluar1",
"description": "",
"type": {
"id": 1,
"value": "Account Manager"
}
},
{
"id": 671,
"name": "Gluar2",
"description": "",
"type": {
"id": 2,
"value": "Product Manager"
}
}
],
"metadata": {"errors": []}
}


With that JSON response the converted XML is :
<xml/>


Any one has an idea why conversion fails ?

For me it looks like a bug because the JSON looks normal...

Thanks for your help,

Vincent.

3 Replies

  • Hi,

    Please check the error log tab in SoapUI. There must be an exception that was encountered when trying to convert the XML to JSON. The empty array [] could be what is causing the error.
  • turman's avatar
    turman
    Occasional Contributor
    Hi Mr James,

    Thanks for your reponse.

    I don't think that the problem comes from the empty array because my other services have the same empty array and the XML conversion is working well (and a empty array is not illegal in JSON as far as I know).

    But the error log is talking about a double slash in path :
    Thu Jul 03 16:57:30 CEST 2014:ERROR:nu.xom.MalformedURIException: Double slash (//) in path
    nu.xom.MalformedURIException: Double slash (//) in path
    at nu.xom.Verifier.throwMalformedURIException(Verifier.java:161)
    at nu.xom.Verifier.checkPath(Verifier.java:396)
    at nu.xom.Verifier.checkAbsoluteURIReference(Verifier.java:907)
    at nu.xom.Element._setNamespaceURI(Element.java:869)
    at nu.xom.Element.setNamespaceURI(Element.java:852)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONObject(JsonXmlSerializer.java:1173)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:735)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:690)
    at com.eviware.soapui.impl.rest.support.handlers.JsonMediaTypeHandler.createXmlRepresentation(JsonMediaTypeHandler.java:69)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpResponse.getContentAsXml(BaseHttpResponse.java:462)
    at com.eviware.soapui.impl.rest.panels.request.inspectors.schema.InferredSchemaInspector.afterSubmit(InferredSchemaInspector.java:113)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:161)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Thu Jul 03 18:40:11 CEST 2014:ERROR:nu.xom.MalformedURIException: Double slash (//) in path
    nu.xom.MalformedURIException: Double slash (//) in path
    at nu.xom.Verifier.throwMalformedURIException(Verifier.java:161)
    at nu.xom.Verifier.checkPath(Verifier.java:396)
    at nu.xom.Verifier.checkAbsoluteURIReference(Verifier.java:907)
    at nu.xom.Element._setNamespaceURI(Element.java:869)
    at nu.xom.Element.setNamespaceURI(Element.java:852)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONObject(JsonXmlSerializer.java:1173)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:735)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:690)
    at com.eviware.soapui.impl.rest.support.handlers.JsonMediaTypeHandler.createXmlRepresentation(JsonMediaTypeHandler.java:69)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpResponse.getContentAsXml(BaseHttpResponse.java:462)
    at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.propertyChange(RestTestRequestStep.java:485)
    at java.beans.PropertyChangeSupport.fire(Unknown Source)
    at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
    at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
    at com.eviware.soapui.model.support.AbstractModelItem.notifyPropertyChanged(AbstractModelItem.java:90)
    at com.eviware.soapui.impl.support.AbstractHttpRequest.setResponse(AbstractHttpRequest.java:896)
    at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequest.setResponse(RestTestRequest.java:140)
    at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.run(RestTestRequestStep.java:927)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


    Strange I don't see where a double slash could be there
  • turman's avatar
    turman
    Occasional Contributor
    Ok I found the problem : my resource URL had a trailing slash. Without it the XML conversion is fine.

    Sorry to have blamed SoapUI !