gefei
gefei

Reputation: 19786

axis2: content length must be specified

I am writing a SOAP service client using axis2. I generated the client code with wsdl2java, then I try to

Request req = new Request();
req.setParameter("XXX");

ServiceStub stub = new ServiceStub();                                     
stub.remoteService(req);            

At runtime, I get an AxisFault: Content length must be specified

Any idea of what's going wrong or how to specify content length?

Upvotes: 0

Views: 3254

Answers (2)

Anshu
Anshu

Reputation: 7853

I believe the Axis2 will include the content-length value in the HTTP header if you disable the chunking by default

As per the XML RPC specifications:

Header requirements

The format of the URI in the first line of the header is not specified. For example, it could be empty, a single slash, if the server is only handling XML-RPC calls. However, if the server is handling a mix of incoming HTTP requests, we allow the URI to help route the request to the code that handles XML-RPC requests. (In the example, the URI is /RPC2, telling the server to route the request to the "RPC2" responder.)

A User-Agent and Host must be specified.

The Content-Type is text/xml.

The Content-Length must be specified and must be correct.

Upvotes: 1

gefei
gefei

Reputation: 19786

OK, I finally got it. According to this it's a long-known issue of axis.

Using axis2, I added the following to the my service stub

_operationClient.getOptions().setProperty(HTTPConstants.CHUNKED, false);

and it worked fine!

Upvotes: 3

Related Questions