“org.xml.sax.SAXParseException:文件过早结束。”解析模式时
我正在编写一个在 Linux JBoss 5.0.1 / JBossWS Native 3.1.1 上运行的 Web 服务客户端,它调用在 Windows Tomcat 6.0.29 / Metro Stack 上运行的服务。
WSDL 和引用的 XSD 文件可以通过浏览器访问,而且我编写的 JUnit 测试也工作得很好。但是当客户端在 JBoss 中运行时,我得到以下堆栈跟踪:
Caused by: org.jboss.ws.metadata.wsdl.WSDLException: javax.wsdl.WSDLException: WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'http://server:8280/ValueListService/?xsd=1'.: org.xml.sax.SAXParseException: Premature end of file.
at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:152)
at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:293)
at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:84)
at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegateImpl.java:138)
at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
at javax.xml.ws.Service.<init>(Service.java:79)
at javax.xml.ws.Service.create(Service.java:96)
at ...
通过调试 JBossWS WSDL 实现,我发现从引用的 XSD 创建的 InputStream 为 null。这通常让我假设客户端和服务器之间存在某种网络问题(或防火墙)。这一切都非常令人困惑,因为我在同一台机器上运行单元测试,所以不可能是因为这个。
I'm writing a webservice client running on Linux JBoss 5.0.1 / JBossWS Native 3.1.1 which is calling a service running on a Windows Tomcat 6.0.29 / Metro Stack.
The WSDLs and the referenced XSD files are accessible via browser and also the JUnit tests I wrote work just fine. But when the client is running inside JBoss, I get the following stacktrace:
Caused by: org.jboss.ws.metadata.wsdl.WSDLException: javax.wsdl.WSDLException: WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'http://server:8280/ValueListService/?xsd=1'.: org.xml.sax.SAXParseException: Premature end of file.
at org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory.parse(WSDLDefinitionsFactory.java:152)
at org.jboss.ws.metadata.umdm.ServiceMetaData.getWsdlDefinitions(ServiceMetaData.java:293)
at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.buildMetaData(JAXWSClientMetaDataBuilder.java:84)
at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.<init>(ServiceDelegateImpl.java:138)
at org.jboss.ws.core.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:63)
at javax.xml.ws.Service.<init>(Service.java:79)
at javax.xml.ws.Service.create(Service.java:96)
at ...
By debugging the JBossWS WSDL implementation I found, that the InputStream which is created from the referenced XSD is null. This normally points me to the assumption, that there is some kind of networking issue (or firewall) between the client and the server. This is all very confusing, as I have the Unit tests running on the same machine, so it can't be because of that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我花了很长时间才理解 WS 实现的内部工作原理,但现在我得到了解决方案。
问题出在 JBoss 本机中,它无法处理 Metro 生成的 URL。我现在的解决方法是从本地资源加载 WSDL 和 XSD,并手动将端点地址更改为真实服务器地址。
@artbristol,感谢您的帮助。
It took me quite a while to understand the inner workings of the WS implementation, but I got a solution now.
The problem resides within JBoss native, which cannot cope with the Metro generated URLs. My woraround for now is loading the WSDLs and XSDs from my local resources and changing the endpoint address to the real server address manually.
@artbristol, thanks for your help.