【发布时间】:2013-09-30 10:50:07
【问题描述】:
我尝试创建一个 Web 服务并且应该通过推送接收数据。我使用来自 WSDL 的 NetBeans 生成了一个 Web 服务。不幸的是,我总是在输出中:
由于异常,无法创建 SOAP 消息:XML 阅读器错误: com.ctc.wstx.exc.WstxParsingException:无效的 UTF-8 起始字节 0x8b (在字符#2,字节#-1)引起:com.ctc.wstx.exc.WstxIOException: 无效的 UTF-8 起始字节 0x8b(在字符 #2,字节 #-1)
如果我更改绑定类型:
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
我明白了:
不支持的 Content-Type: text/html 支持的有: [应用程序/soap+xml]
所以它是 1.1 SOAP 协议(更改为 SOAP11HTTP_BINDING)。
我使用 Glassfish 3.1.2.2 并且已经将 JVM-Options 更改为:
-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 压缩的请求。那么如何解压压缩后的答案呢?
【问题讨论】:
标签: java web-services soap utf-8 glassfish