java - 无法从 Web 服务客户端访问本地主机 (TOMCAT) 上的 WSDL

标签 java web-services tomcat cxf

我正在尝试用 Java 创建简单的 Web 服务 HelloWorld。我创建方法 HelloWorld。然后使用 CXF 框架我生成网络服务和客户端。服务器是tomcat。但是当我尝试从客户端访问网络服务时,我得到了这个:

Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:150)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Service.java:56)
at sk.fiit.bado.testws.klient.TestWSService.<init>(TestWSService.java:43)
at sk.fiit.bado.testws.klient.TestSEI_TestWSPort_Client.main(TestSEI_TestWSPort_Client.java:48)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:94)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
... 4 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://localhost:8080/TestService/services/TestWSPort?wsdl'.: java.io.FileNotFoundException: http://localhost:8080/TestService/services/TestWSPort?wsdl
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:244)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:191)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
... 6 more
Caused by: java.io.FileNotFoundException: http://localhost:8080/TestService/services/TestWSPort?wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1434)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
... 12 more

我猜这是关于 WSDL 文件的。因为我也无法访问它。帮助将不胜感激。

最佳答案

您的堆栈已经告诉您出了什么问题。找不到 wsdl 文件:

Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://localhost:8080/TestService/services/TestWSPort?wsdl'.: java.io.FileNotFoundException: http://localhost:8080/TestService/services/TestWSPort?wsdl

关于java - 无法从 Web 服务客户端访问本地主机 (TOMCAT) 上的 WSDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9771479/

相关文章:

java - 如何使用 Tomcat 打开 Java Spring 项目中的文件

java - setFocus() 始终为假

java - 在表单中设置参数

java - JSP/TomCat 中不显示 img

java - 在 Java 中使用 Contract-First 的 Web 服务周期

web-services - HBase上的Web服务

java - 如果出现 SurefireBooterForkException,如何使构建失败?

java - 如何设置 Eclipse 以开始使用 Axis2 编写 Web 服务

tomcat - 我可以将 Grails 设置为自动编译而不调用 run-app 吗?

java - 无法将 JSP 项目作为动态 Web 项目导入 Eclipse