Web Services-Common Pitfalls and Troubleshooting

Last modified by Matthew Taylor on 2008/09/13 12:25

NullPointerException calling WebService with Axis

If you get an exception like the following:

Caused by: java.lang.NullPointerException
 at java.util.Hashtable.put(Hashtable.java:396)
 at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:395)
 at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:246)
 at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
 at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
 at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
 at org.apache.axis.client.Call.invoke(Call.java:2553)
 at org.apache.axis.client.Call.invoke(Call.java:2248)
 ... 5 more

It's most likely because you are using Java 1.5 with Axis 1.1. If you want your client to run on Java 1.5, you will need to upgrade to Axis 1.2RC2.

Losing Session with Axis Client

For more information about cookie-based sessions with Axis clients, read the Consuming with Axis in Java section.

SAXParseException only when clients use https

If, in WebObjects 5.4.x, your web services work normally over insecure http connections, but fail with the following exception when connecting via HTTPS to Apache (using the WebObjects apache adaptor):

org.xml.sax.SAXParseException: Premature end of file.
 at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source
 at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
 at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
 at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
 at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source))
 ... more

You will need to add additional information to the file server.wsdd to tell Apache AXIS what to do when it believes the transport mechanism is 'https.' AXIS will make the transport mechanism determination based on the HTTP header information sent to your application by the Apache WebObjects adaptor (which may include: HTTPS:on and SERVER_PORT:443). If no entry is made to tell AXIS how to handle 'https', it will assume the incoming data from the adaptor is encrypted via SSL, even though the communication between the adaptor and the instance is actually in the clear. To change the behavior of AXIS to handle these cases in the same way as http connections, change the file server.wsdd from:

<transport name="http">
 <requestFlow>
 <handler type="HTTPActionHandler"/>
 <handler type="URLMapper"/>
 </requestFlow>
 </transport>

To:

<transport name="http">
 <requestFlow>
 <handler type="HTTPActionHandler"/>
 <handler type="URLMapper"/>
 </requestFlow>
 </transport>
 <transport name="https">
 <requestFlow>
 <handler type="HTTPActionHandler"/>
 <handler type="URLMapper"/>
 </requestFlow>
 </transport>