加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – jax-ws客户端问题

发布时间:2020-12-15 02:27:43 所属栏目:Java 来源:网络整理
导读:我通过执行命令生成了一个jax-ws客户端: C:wsdlwsimport -keep -verbose -d generated HealthMobilitySequenceArtifacts.wsdl wsdl文件中的服务地址是: soap:address location="http://localhost:8585/active-bpel/services/HealthMobilitySequence 好吧,
我通过执行命令生成了一个jax-ws客户端:

C:wsdl>wsimport -keep -verbose -d generated HealthMobilitySequenceArtifacts.wsdl

wsdl文件中的服务地址是:

    soap:address location="http://localhost:8585/active-bpel/services/HealthMobilitySequence

好吧,我已经将生成的文件打包在jar(clentjaxw.jar)中,并且我在eclipse项目中使用它作为导入的库来进行一些测试.

事实是我能够毫无问题地进行测试,但是当我向同事提供clientjaxw.jar时,他在执行期间出现以下错误:

    Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
        at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(Unknown Source)
        at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
        at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
        at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
        at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
        at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
        at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
        at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
        at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
        at $Proxy29.bookTreatment(Unknown Source)
        at test.TestJaxWS.main(TestJaxWS.java:32)
    Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at sun.net.NetworkClient.doConnect(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
        ... 15 more

我不明白这个问题:然而,同事能够在该地址的浏览器中可视化服务,也就是ping localhost运行.此外,我已经检查过他不是代理人.

你对这个问题的原因有什么看法吗?

更新:
我必须添加新的细节:我发现同事可以通过浏览器访问:http://localhost:8585/active-bpel/services/HealthMobilitySequence?wsdl但是如果他试图访问:http://127.0.0.1:8585 / active-bpel / services / HealthMobilitySequence? wsdl或使用ip地址代替localhost的同一个url,他失败了.在我的机器上我没有这样的问题我能够访问所有可能:localhost,机器名称,127.0.0.1,ipaddress.

所以我认为这可能是问题,我的意思是我想通过java,在打开java套接字连接之前,在使用ip地址(或127.0.0.1)代替localhost和访问权限的新套接字连接之前翻译了url http://localhost:8585/active-bpel/services/HealthMobilitySequence失败.所以似乎问题是由于操作系统,因为我们在操作系统中共享完全相同的配置(在我的机器上赢得xp,在他的机器上获得vista).

一些想法?谢谢

更新:嗨再次,由于某种原因改变机器(总是64位)同事解决了我描述的问题.无论如何,他还有另一个问题,它不依赖于客户端,因为他也通过调用eclipse web explorer来体验相同的问题.
例外情况如下:
java.lang.ClassCastException:com.sun.xml.internal.messaging.saaj.soap.ver1_1.Envelope1_1Impl无法强制转换为java.lang.String

org.apache.axis.SOAPPart.getAsString(SOAPPart.java:554)

    org.apache.axis.SOAPPart.writeTo(SOAPPart.java:322)

    org.apache.axis.SOAPPart.writeTo(SOAPPart.java:269)

    org.apache.axis.Message.writeTo(Message.java:539)

    org.apache.axis.transport.http.AxisServlet.sendResponse(AxisServlet.java:902)

    org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:777)

    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)

    org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)

    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

请注意他要调用的Web服务是在Tomcat 5.5.27中运行的ActiveBPEL(版本5.0.2)中部署的bpel进程之一.此外它的配置如下:OP:windows 7,jdk:1.6,arch:64 bit而mine是:OP:windows xp,arch:32 bit.
你对这个问题有所了解吗?

提前致谢

解决方法

我在构建和测试ActiveBPEL代码时遇到了这个问题.我的解决方案是将java.xml.soap.MessageFactory显式映射到Axis实现.这避免了两个SOAP堆栈之间的不兼容性.

映射可以通过几种不同的方式完成.

>使用系统属性-Djavax.xml.soap.MessageFactory = org.apache.axis.soap.MessageFactoryImpl
>在类路径中包含工厂文件:/META-INF/javax.xml.soap.MessageFactory,其中此文件的内容是单行文本:org.apache.axis.soap.MessageFactoryImpl

如果您正在构建AE源,则后者是首选机制,可以添加到org.activebpel.rt.axis.bpel项目中.如果您正在使用二进制文件,那么您可能需要在容器的启动脚本(Tomcat / Jetty)上创建自定义属性.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读