Archive

Archive for the ‘axis’ Category

Axis returned (0)null – a solution

15 April 2009 21 comments

This is a very weird error I was getting a few days ago when I was running Apache Axis. If you output the stack trace you will get the following error

AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (0)null
faultActor:
faultNode:
faultDetail:
{}:return code:  0

{http://xml.apache.org/axis/}HttpErrorCode:0

(0)null
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)

If you delve into the apache axis source code you will see that this is actually a network error. There is a variable that holds the network code. This variable is assigned to zero in the beginning of the axis class. At some point the developers of axis read the HTTP responses and assign the HTTP code to this network code variable. But along the flow of the class an exception occurs and this network code remains zero. The null you get next to it is the actual error message description which is null because the exception doesn’t assign a message to it (exactly like it happens with the zero).

This occurred to me when I tried to use a DIME attachment with axis. It seems that axis 1 (not sure about axis 2) does not support DIME attachments properly. In order to resolve this (and the error above) you will need to use another transport handler. There is a solution described in the Axis attachment problems page. Although the solution described in the link is for a different problem, the same solution can be applied for the (0)null issue.

As the page explains the solution is to change the client-config.wsdd file (from within the org\apache\axis\client) and assign a different handler to the file, like the following

<deployment name="defaultClientConfig" ...>
<transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/>
...
</deployment>

In order to do this you will need to extract all the classes in the axis.jar file, change the client-config.wsdd, and recreate the axis.jar file. You will also need to include the apache commons http client 3.1 and commons-codec 1.3 in your classpath.

The second solution, if you don’t want to recreate the axis.jar file, is to use an EngineConfiguration and pass the new handler to it programmatically.

EngineConfiguration engine = EngineConfigurationFactoryFinder.newFactory().getClientEngineConfig();
SimpleProvider provider = new SimpleProvider(engine);
provider.deployTransport("http", new CommonsHTTPSender());

Then you will need to pass this provider instance in your web service class that extends the org.apache.axis.client.Service. This can be done by passing it in the constructor of your service class.

Categories: axis, Web Services