gpt4 book ai didi

java - 推送网络服务 : Invalid UTF-8 start byte

转载 作者:行者123 更新时间:2023-12-01 04:19:31 30 4
gpt4 key购买 nike

我尝试创建一个 Web 服务,并且应该通过推送接收数据。我使用 NetBeans 从 WSDL 生成了一个 Web 服务。不幸的是我总是在输出中:

Couldn't create SOAP message due to exception: XML reader error: com.ctc.wstx.exc.WstxParsingException: Invalid UTF-8 start byte 0x8b (at char #2, byte #-1) Caused by: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 start byte 0x8b (at char #2, byte #-1)

如果我更改绑定(bind)类型:

@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)

我得到:

Unsupported Content-Type: text/html Supported ones are: [application/soap+xml]

所以它是 1.1 SOAP 协议(protocol)(​​更改为 SOAP11HTTP_BINDING)。

我使用 Glassfish 3.1.2.2 并将 JVM 选项更改为:

-Dfile.encoding=UTF-8

-Dfile.encoding=UTF8

但没有帮助。 UTF16 或 UTF-16 会引发异常。

这就是我的 pom.xml 的样子:

...
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>PushService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>${project.build.directory}/jaxws/stale/PushService.stale</staleFile>
</configuration>
<id>wsimport-generate-PushService</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>
...

如何解决这个问题?

更新:原因是服务发送了压缩后的请求。那么如何解压 gzip 后的答案呢?

最佳答案

显然 Glassfish 还不支持 gzip 解码。所以我实现了一个过滤器,它对输入进行解码:

@WebFilter(filterName = "GZipInputFilter", urlPatterns = {"/*"})
public class GZipInputFilter implements Filter

关于java - 推送网络服务 : Invalid UTF-8 start byte,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19092341/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com