Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intercept XML parsing errors in JAXB processing of SOAP messages?

Can I use JAXB to intercept XML parsing to inspect a payload?

I have generated code bindings for a SharePoint WSDL using java's wsimport tool. I'm calling a SOAP method called GetListItems in SharePoint, the generated code is doing the XML parsing for me that comes back from the server.

That parse is failing; it's a known issue in SharePoint that it's possible for users to put special characters in some things that breaks the XML that SharePoint is generating.

This stack trace gives the hint Character reference "&#]) (notice the lack of closing double quote there) - my best guess right now is there's a non-printable character or something funky in the XML that is busting the parse. Fixing it begins with knowing more about how it's happening. 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's 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
like image 482
FrobberOfBits Avatar asked Dec 13 '25 12:12

FrobberOfBits


1 Answers

You could turn on logging of SOAP messages in your client. See for instance Tracing XML request/responses with JAX-WS to log to the console.

like image 94
wero Avatar answered Dec 16 '25 06:12

wero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!