【问题标题】:Chunked input stream failed to receive valid chunk size:<?xmlversion="1.0"分块输入流无法接收有效的块大小:<?xmlversion="1.0"
【发布时间】:2023-03-23 03:38:01
【问题描述】:

我使用的是 Axis 1.4 版本并使用 org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask 来生成客户端代码。但是,当我尝试拨打电话时出现以下错误,提前致谢

  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)

build.xml 中的目标是,

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

【问题讨论】:

  • 您可以将您的 Ant 目标添加到问题中吗?

标签: java web-services soap ant axis


【解决方案1】:

为了解决稍后看到此问题的用户,我找到了此异常的根本原因。 Axis 1.4 使用 HTTP 1.0 发送“NoN Chunked Streams”中的数据。 如果这些消息命中服务器 HTTP 1.1,其中预期数据在“分块流”中可能会出现此错误。有关此编码的更多信息可以在 chunked transfer encoding 中找到。

我已经解决了(不升级 Axis),方法是添加一个名为 deploy-client.wssd 的文件,该文件由以下几行组成。

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

这将告诉 Axis 使用默认情况下使用 HTTP 1.1 的 commonsHTTPSender。希望它对某人有所帮助。

【讨论】:

    【解决方案2】:

    按照 Sasi 所述创建 deploy-client.wsdd 文件。

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

    为你的 pom 文件添加依赖

    <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.7.7</version>
    </dependency>
    

    然后在您的代码中处理该文件

    System.setProperty("axis.ClientConfigFile", path-of-your-file);
    

    【讨论】:

      猜你喜欢
      • 2020-07-04
      • 1970-01-01
      • 2018-11-24
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 2017-01-18
      相关资源
      最近更新 更多