Forum Discussion

RPfrimmer's avatar
RPfrimmer
Occasional Contributor
12 years ago

JSON response msgs not converted to XML

Please forgive me but I'm new to working with JSON and REST web services.

I am currently running into an issue with one of the new web services we are developing. For some reason the JSON response received cannot be rendered as XML or in the Outline view in SoapUI.

I have checked this in both SoapUI Pro 4.6.4 as well as 5.0.0-beta. Other web services seem to be fine it is just this one service. I've tried taking the JSON content returned in the response and running it through a couple JSON validators to make sure that the content is well formed and it passed validation in each one I tried.

I have noticed on the forums that others have run into similar issues on occasion, and in some of the examples the response was not valid JSON and in others it was. I saw someone post a work around with the 'Replace Duplicate forward Slashes' option in the HTTP Settings, but when I try this it doesn't change how this behaves for me.

If I can't reliably access the XML or Outline views of the responses, it will create a significant challenge performing and maintaining the assertions against the response in my test cases.

Any assistance from the community would be greatly appreciated.

Below is a sample of the response i'm working with.

{"GuestBookings": {"Folio": [
{
"$": {"app": "Hotel"},
"AppFolioId": ["5"],
"Location": [""],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"ArrivalDate": ["2014-05-05000000"],
"DepartureDate": ["2014-05-09000000"],
"NumAdults": ["2"],
"NumYouth": ["2"],
"NumChildren": ["2"],
"TotalGuests": ["6"],
"RoomNumber": [""],
"RoomType": ["English - Room Type Desc"],
"RateType": ["English - Rate Name Field"],
"RateDescription": ["English - Rate Desc Field"],
"NetAmount": [" 1400.00"],
"GrossAmount": [" 1803.24"]
},
{
"$": {"app": "Golf"},
"AppFolioId": ["43723"],
"Location": ["Golf - 999"],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"StartDate": ["2014-05-05095000"],
"FinishDate": [""],
"Details": ["Links"],
"NetAmount": [" .00"],
"GrossAmount": [""]
},
{
"$": {"app": "Golf"},
"AppFolioId": ["43723"],
"Location": ["Golf - 999"],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"StartDate": ["2014-05-05095000"],
"FinishDate": [""],
"Details": ["Links"],
"NetAmount": [" .00"],
"GrossAmount": [""]
},
{
"$": {"app": "Golf"},
"AppFolioId": ["43725"],
"Location": ["Golf - 999"],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"StartDate": ["2014-05-05131000"],
"FinishDate": [""],
"Details": ["Links"],
"NetAmount": [" .00"],
"GrossAmount": [""]
},
{
"$": {"app": "Golf"},
"AppFolioId": ["43725"],
"Location": ["Golf - 999"],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"StartDate": ["2014-05-05131000"],
"FinishDate": [""],
"Details": ["Links"],
"NetAmount": [" .00"],
"GrossAmount": [""]
},
{
"$": {"app": "Golf"},
"AppFolioId": ["43725"],
"Location": ["Golf - 999"],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"StartDate": ["2014-05-05131000"],
"FinishDate": [""],
"Details": ["Links"],
"NetAmount": [" .00"],
"GrossAmount": [""]
},
{
"$": {"app": "Golf"},
"AppFolioId": ["43725"],
"Location": ["Golf - 999"],
"Customer": [ {
"CustomerId": ["115389"],
"Salutation": ["Mr."],
"FirstName": ["John"],
"LastName": ["Smith"]
}],
"StartDate": ["2014-05-05131000"],
"FinishDate": [""],
"Details": ["Links"],
"NetAmount": [" .00"],
"GrossAmount": [""]
}
]}}

6 Replies

  • Hi,

    The JSON seems valid. Can you share the raw response you are getting and a screenshot of your request ?

    Also, in there any error that appears on the log, when you receive your response?

    Thanks,

    Giscard
    SmartBear Support
  • RPfrimmer's avatar
    RPfrimmer
    Occasional Contributor
    Here is a screenshot of the raw request



    Here is the content of the Raw request displayed in soapui

    HTTP/1.1 200 OK
    X-Powered-By: Express
    Content-Type: application/json; charset=utf-8
    Content-Length: 5787
    ETag: "-960988189"
    Date: Wed, 26 Mar 2014 18:55:27 GMT
    Connection: keep-alive

    {
    "GuestBookings": {
    "Folio": [
    {
    "$": {
    "app": "Hotel"
    },
    "AppFolioId": [
    "5"
    ],
    "Location": [
    ""
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "ArrivalDate": [
    "2014-05-05000000"
    ],
    "DepartureDate": [
    "2014-05-09000000"
    ],
    "NumAdults": [
    "2"
    ],
    "NumYouth": [
    "2"
    ],
    "NumChildren": [
    "2"
    ],
    "TotalGuests": [
    "6"
    ],
    "RoomNumber": [
    ""
    ],
    "RoomType": [
    "English - Room Type Desc"
    ],
    "RateType": [
    "English - Rate Name Field"
    ],
    "RateDescription": [
    "English - Rate Desc Field"
    ],
    "NetAmount": [
    " 1400.00"
    ],
    "GrossAmount": [
    " 1803.24"
    ]
    },
    {
    "$": {
    "app": "Golf"
    },
    "AppFolioId": [
    "43723"
    ],
    "Location": [
    "Golf - 999"
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "StartDate": [
    "2014-05-05095000"
    ],
    "FinishDate": [
    ""
    ],
    "Details": [
    "Links"
    ],
    "NetAmount": [
    " .00"
    ],
    "GrossAmount": [
    ""
    ]
    },
    {
    "$": {
    "app": "Golf"
    },
    "AppFolioId": [
    "43723"
    ],
    "Location": [
    "Golf - 999"
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "StartDate": [
    "2014-05-05095000"
    ],
    "FinishDate": [
    ""
    ],
    "Details": [
    "Links"
    ],
    "NetAmount": [
    " .00"
    ],
    "GrossAmount": [
    ""
    ]
    },
    {
    "$": {
    "app": "Golf"
    },
    "AppFolioId": [
    "43725"
    ],
    "Location": [
    "Golf - 999"
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "StartDate": [
    "2014-05-05131000"
    ],
    "FinishDate": [
    ""
    ],
    "Details": [
    "Links"
    ],
    "NetAmount": [
    " .00"
    ],
    "GrossAmount": [
    ""
    ]
    },
    {
    "$": {
    "app": "Golf"
    },
    "AppFolioId": [
    "43725"
    ],
    "Location": [
    "Golf - 999"
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "StartDate": [
    "2014-05-05131000"
    ],
    "FinishDate": [
    ""
    ],
    "Details": [
    "Links"
    ],
    "NetAmount": [
    " .00"
    ],
    "GrossAmount": [
    ""
    ]
    },
    {
    "$": {
    "app": "Golf"
    },
    "AppFolioId": [
    "43725"
    ],
    "Location": [
    "Golf - 999"
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "StartDate": [
    "2014-05-05131000"
    ],
    "FinishDate": [
    ""
    ],
    "Details": [
    "Links"
    ],
    "NetAmount": [
    " .00"
    ],
    "GrossAmount": [
    ""
    ]
    },
    {
    "$": {
    "app": "Golf"
    },
    "AppFolioId": [
    "43725"
    ],
    "Location": [
    "Golf - 999"
    ],
    "Customer": [
    {
    "CustomerId": [
    "115389"
    ],
    "Salutation": [
    "Mr."
    ],
    "FirstName": [
    "John"
    ],
    "LastName": [
    "Smith"
    ]
    }
    ],
    "StartDate": [
    "2014-05-05131000"
    ],
    "FinishDate": [
    ""
    ],
    "Details": [
    "Links"
    ],
    "NetAmount": [
    " .00"
    ],
    "GrossAmount": [
    ""
    ]
    }
    ]
    }
    }


    Forgive me but I hadn't checked the logs before but it does look like there is an error.

    SoapUI Error
    Wed Mar 26 15:07:36 EDT 2014:ERROR:An error occurred [Illegal path character {], see error log for details


    Error Log
    Wed Mar 26 15:07:36 EDT 2014:ERROR:nu.xom.MalformedURIException: Illegal path character {
    nu.xom.MalformedURIException: Illegal path character {
    at nu.xom.Verifier.throwMalformedURIException(Verifier.java:161)
    at nu.xom.Verifier.checkPath(Verifier.java:416)
    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:1159)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:721)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:676)
    at com.eviware.soapui.impl.rest.support.handlers.JsonMediaTypeHandler.createXmlRepresentation(JsonMediaTypeHandler.java:65)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpResponse.getContentAsXml(BaseHttpResponse.java:458)
    at com.eviware.soapui.impl.rest.panels.request.inspectors.schema.InferredSchemaInspector.afterSubmit(InferredSchemaInspector.java:109)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:157)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.submitRequest(WsdlSubmit.java:76)
    at com.eviware.soapui.impl.rest.RestRequest.submit(RestRequest.java:211)
    at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.run(RestTestRequestStep.java:901)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:235)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:148)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:43)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
    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)
  • RPfrimmer's avatar
    RPfrimmer
    Occasional Contributor
    I just tried it with the 4.6.4 nightly build and I'm getting a different error now.

    Should I be opening a support ticket for this then?

    Wed Mar 26 17:04:14 EDT 2014:ERROR:An error occurred [NCNames cannot be empty], see error log for details


    Wed Mar 26 17:04:14 EDT 2014:ERROR:nu.xom.IllegalNameException: NCNames cannot be empty
    nu.xom.IllegalNameException: NCNames cannot be empty
    at nu.xom.Verifier.throwIllegalNameException(Verifier.java:147)
    at nu.xom.Verifier.checkNCName(Verifier.java:121)
    at nu.xom.Element._setLocalName(Element.java:832)
    at nu.xom.Element.<init>(Element.java:112)
    at nu.xom.Element.<init>(Element.java:76)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer$CustomElement.<init>(JsonXmlSerializer.java:1730)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.newElement(JsonXmlSerializer.java:1076)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONObject(JsonXmlSerializer.java:1241)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONValue(JsonXmlSerializer.java:1311)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONArray(JsonXmlSerializer.java:1129)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONValue(JsonXmlSerializer.java:1303)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONObject(JsonXmlSerializer.java:1242)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONValue(JsonXmlSerializer.java:1311)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.processJSONObject(JsonXmlSerializer.java:1242)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:721)
    at com.eviware.soapui.impl.rest.support.handlers.JsonXmlSerializer.write(JsonXmlSerializer.java:676)
    at com.eviware.soapui.impl.rest.support.handlers.JsonMediaTypeHandler.createXmlRepresentation(JsonMediaTypeHandler.java:61)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpResponse.getContentAsXml(BaseHttpResponse.java:435)
    at com.eviware.soapui.impl.rest.panels.request.inspectors.schema.InferredSchemaInspector.afterSubmit(InferredSchemaInspector.java:109)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:157)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.submitRequest(WsdlSubmit.java:76)
    at com.eviware.soapui.impl.rest.RestRequest.submit(RestRequest.java:220)
    at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.run(RestTestRequestStep.java:900)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:235)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:148)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:43)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
    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)
  • Yes please, that would be good. Please include the lastest log.

    Thanks,

    Giscard
    SmartBear Support
  • RPfrimmer's avatar
    RPfrimmer
    Occasional Contributor
    For the benefit of the community the issue did lie in the content of the JSON response.

    The $ which is a valid character in JSON is not a valid character in XML for object and attribute names. The parser was not handling this properly.

    It was also not handing it properly for # or @ as well which are all valid JSON characters.