Forum Discussion

dseel's avatar
dseel
Contributor
14 years ago

Mock Service Error With JSON

Hi:

I'm using SOAPUI Pro 3.5.1 to run a REST mock service using a groovy script in the OnRequest tab. When I send a normal XML POST request to the mock service, everything works fine. However, if I send a POST that has json content (application/json) the mock service returns this error:

HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Server: Jetty(6.1.x)

13B
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>Server</faultcode>
<faultstring>org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

Here is the error log:
Wed Aug 11 09:31:50 EDT 2010:ERROR:com.eviware.soapui.impl.wsdl.mock.DispatchException: org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA
com.eviware.soapui.impl.wsdl.mock.DispatchException: org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:397)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:701)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:842)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3486)
at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:712)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:696)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:683)
at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:208)
at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:580)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRequest.getRequestXmlObject(WsdlMockRequest.java:271)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRequest.initPostRequest(WsdlMockRequest.java:148)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRequest.<init>(WsdlMockRequest.java:103)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:377)
... 11 more
Caused by: org.xml.sax.SAXParseException: Unexpected element: CDATA
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(Piccolo.java:1038)
at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:723)
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3454)
... 20 more

I've tried this in 3.6 beta 2 with the same result. Please let me know if there is a workaround or if it can be fixed.

Thanks,
Dave