Search code examples
javaapache-axiswebservice-client

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?


Solution

  • 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.