当前位置: 首页 > 知识库问答 >
问题:

CXF创建内部网客户端失败

卢晟
2023-03-14

我使用wsdl2java生成代码,并成功创建web服务客户端来调用服务。但是当我把我的程序放在服务器机器上时,程序不能创建网络服务client.if机器可以访问互联网,一切正常。所以我认为这个例外是因为cxf不能访问http://schemas.xmlsoap.org/soap/encoding/

stacktrace:

14-11-20 18:51:20 create WSUtil err: [main-com.jadic.ws.WSUtil]
javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:151) ~[cxf-rt-frontend-jaxws-2.7.12.jar:2.7.12]
    at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101) ~[cxf-rt-frontend-jaxws-2.7.12.jar:2.7.12]
    at javax.xml.ws.Service.<init>(Unknown Source) ~[na:1.6.0_05]
    at com.jadic.ws.czsmk.CenterProcess.<init>(CenterProcess.java:43) ~[stserver-1.0.0.jar:na]
    at com.jadic.ws.WSUtil.createServiceClient(WSUtil.java:106) [stserver-1.0.0.jar:na]
    at com.jadic.ws.WSUtil.<init>(WSUtil.java:95) [stserver-1.0.0.jar:na]
    at com.jadic.ws.WSUtil.getWsUtil(WSUtil.java:76) [stserver-1.0.0.jar:na]
    at com.jadic.STServer.<init>(STServer.java:34) [stserver-1.0.0.jar:na]
    at com.jadic.STServer.main(STServer.java:57) [stserver-1.0.0.jar:na]
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100) ~[cxf-rt-core-2.7.12.jar:2.7.12]
    at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204) ~[cxf-rt-frontend-jaxws-2.7.12.jar:2.7.12]
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149) ~[cxf-rt-frontend-jaxws-2.7.12.jar:2.7.12]
    ... 8 common frames omitted
Caused by: javax.wsdl.WSDLException: WSDLException (at /definitions/types/schema): faultCode=PARSER_ERROR: Problem parsing 'http://schemas.xmlsoap.org/soap/encoding/'.: java.net.UnknownHostException: schemas.xmlsoap.org
    at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198) ~[wsdl4j-1.6.3.jar:1.6.3]
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:830) ~[wsdl4j-1.6.3.jar:1.6.3]
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(WSDLReaderImpl.java:654) ~[wsdl4j-1.6.3.jar:1.6.3]
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:610) ~[wsdl4j-1.6.3.jar:1.6.3]
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(WSDLReaderImpl.java:320) ~[wsdl4j-1.6.3.jar:1.6.3]
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2352) ~[wsdl4j-1.6.3.jar:1.6.3]
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:2338) ~[wsdl4j-1.6.3.jar:1.6.3]
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:261) ~[cxf-rt-core-2.7.12.jar:2.7.12]
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:206) ~[cxf-rt-core-2.7.12.jar:2.7.12]
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98) ~[cxf-rt-core-2.7.12.jar:2.7.12]
    ... 10 common frames omitted
Caused by: java.net.UnknownHostException: schemas.xmlsoap.org
    at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.6.0_05]
    at java.net.Socket.connect(Unknown Source) ~[na:1.6.0_05]
    at java.net.Socket.connect(Unknown Source) ~[na:1.6.0_05]
    at sun.net.NetworkClient.doConnect(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.http.HttpClient.openServer(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.http.HttpClient.<init>(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.http.HttpClient.New(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) ~[na:1.6.0_05]
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) ~[na:1.6.0_05]
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) ~[na:1.6.0_05]
    at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2188) ~[wsdl4j-1.6.3.jar:1.6.3]
    ... 19 common frames omitted

那么你能告诉我如何解决这个问题吗,谢谢你的帮助

共有2个答案

宰父学
2023-03-14

尝试在类路径中配置saaj(saaj-impl-1.3.2.jar)。。

戈嘉慕
2023-03-14

删除所有与cxf相关的jar, works.

因为我在代码中没有使用cxf库,所以只需要使用cxf工具来生成存根类

 类似资料:
  • 创建客户端有两种方式,一种是直接使用特化的构造器函数,另一种是使用工厂构造器函数。 第一种方式返回的是具体的客户端结构体指针对象,第二种方式返回的是客户端接口对象。 使用特化的构造器函数创建客户端 特化的构造器函数有下面几个: func NewHTTPClient(uri ...string) (client *HTTPClient) func NewTCPClient(uri ...string

  • 我试图使用wsdl2java maven目标生成客户机,同时指向远程WSDL: 当我试图构建客户机时,目标失败了,因为引用了LocalHost: 是否有任何方法可以使CXF理解localhost引用与wsdl主机相关,并在生成客户端时自动将它们替换为适当的主机名? (我已将实际的服务名称替换为通用名称,如remotehost)

  • 这些其他问题暗示了一个解决方案,但我一直无法实现这一点: 无法解析的绑定http://schemas.xmlsoap.org/wsdl/soap/ ServiceConstructionException在创建CXF web服务客户端时 如何使用Maven“shade”插件将Apache CXF应用程序打包到单片JAR中 当我通过执行启动我的应用程序时,我会得到一个

  • 我有一个Web服务,我试图使用以下客户端代码调用它: 在服务器端(Tomcat),webservice实现如下: CxfAdd。java: CxfAddImpl。java: 但是,当我运行客户端代码时,在服务器端我得到以下错误: 似乎我没有发送ws-addressing属性,有人能帮我找出代码中的错误或缺失吗?非常感谢。

  • 问题:CXF能否基于WS-SecurityPolicy文件自动为客户端配置WS-Security? 如果是的话,是否有任何关于实际这样做的文件?我花了几个小时查看CXF站点并进行搜索,但没有找到答案。 CXF留档显示“CXF 2.2引入了对使用WS-SecurityPolicy配置WSS4J的支持,而不是WS-Security页面上记录的自定义配置”,并且还显示“在CXF 2.2中,如果cxf-r

  • 我正在使用CamelCXFendpoint连接到我的soap服务器。我想为客户端的请求添加超时。我正在为此使用continuationTimeout选项。但它不起作用。请求超时,而不等待我配置的时间。 下面是我的endpoint配置。