How to catch XML parsing errors in JAXB SOAP message processing?

Can JAXB be used to intercept XML parsing for payload validation?

I created code bindings for SharePoint WSDL using java tool wsimport

. I am calling a SOAP method called GetListItems

in SharePoint, the generated code parses the XML for me that is returned from the server.

This parsing does not work; this is a known issue in SharePoint that allows users to put special characters in certain things that break the XML that SharePoint generates.

This stack trace gives a hint Character reference "&#])

(note the lack of a closing double quote) - I am now thinking that there is an unprintable character or something funky in the XML file that exposes the parsing. The fix starts with knowing more about how it happens. Suggestions?

com.sun.xml.internal.ws.encoding.soap.DeserializationException: [failed to localize] Failed to deserialize the response.(javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2399,354]
Message: Character reference "&#])
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:111)
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
        at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
        at com.sun.proxy.$Proxy45.getListItems(Unknown Source)
        at 
        (Snipped bits of my code stack trace)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.simontuffs.onejar.Boot.run(Boot.java:340)
        at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: javax.xml.bind.UnmarshalException
 - with linked exception:
[javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2399,354]
Message: Character reference "&#]
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:470)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:402)
        at com.sun.xml.internal.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:109)
        at com.sun.xml.internal.bind.api.Bridge.unmarshal(Bridge.java:222)
        at com.sun.xml.internal.ws.db.glassfish.BridgeWrapper.unmarshal(BridgeWrapper.java:257)
        at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:635)
        at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:243)
        at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
        at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
        ... 14 more

      

+3


source to share


2 answers


You can enable SOAP message logging in your client. See For example Tracking XML Request / Responses with JAX-WS for Console Login.



+1


source


You can use a packet sniffer like WireShark to find out what's in the XML. Add a filter like "host www.whatever.com" and you can see the XML payload. It will be in the same message as the HTTP code.



0


source







All Articles