Search code examples
javaweb-servicessoapantaxis

Chunked input stream failed to receive valid chunk size:<?xmlversion="1.0"


I am using Axis 1.4 version and used org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask to generate clientcode. However, when i tried to make a call ended up with following error,Thanks in Advance

  java.io.IOException: Chunked input stream failed to receive valid chunk size:<?xmlversion="1.0"
        at org.apache.axis.transport.http.ChunkedInputStream.getChunked(ChunkedInputStream.java:155)
        at org.apache.axis.transport.http.ChunkedInputStream.read(ChunkedInputStream.java:87)
        at java.io.FilterInputStream.read(Unknown Source)
        at org.apache.axis.SOAPPart.getAsBytes(SOAPPart.java:453)
        at org.apache.axis.SOAPPart.getAsString(SOAPPart.java:559)
        at org.apache.axis.Message.getSOAPPartAsString(Message.java:412)
        at org.apache.axis.handlers.LogHandler.logMessages(LogHandler.java:89)
        at org.apache.axis.handlers.LogHandler.invoke(LogHandler.java:68)
        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:190)
        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)

and the target in build.xml is,

<target name="generate-java">   
            <wsdl2java 
                url="${resources.dir}/2.0/popsp.wsdl" 
                debug="true" 
                printstacktraceonfailure="true" 
                output="src">
                <mapping namespace="https://www.dhl.au/popweb/gw/ws/schema/2.0/popws" 
                         package="com.soap.autogen"/>
            </wsdl2java>  
      </target>

Solution

  • to address users who see later this question, I have found the root cause for this Exception. Axis 1.4 uses HTTP 1.0 to send data which are in "NoN Chunked Streams." and if these messages hits Servers HTTP 1.1 ,where data expected is in "chunked streams" will possibly get this error.More about this encoding can found in chunked transfer encoding.

    I have solved(without upgrading Axis), by adding a file called deploy-client.wssd which consists of the following lines.

    <deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
      <transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender"/> 
    </deployment>
    

    This will tells the Axis to use, commonsHTTPSender which uses HTTP 1.1 by default.Hope it helps someone.