如何解决java axis 调用webservice服务器操作异常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何解决java axis 调用webservice服务器操作异常相关的知识,希望对你有一定的参考价值。

安装Eclipse-jee,下载Axis2的最新版本Axis2 1.4.1 Release,其内部结构为 开发前配置:在Eclipse的菜单栏中,Window --> Preferences --> Web Service --> Axis2 Perferences,在Axis2 runtime location中选择Axis2解压缩包的位置,设置好后,点"OK"即行。 新建一个Java Project,命名为"WS_01",在"WS_01"项目上new --> other,找到"Web Services"下面的"Web Service"; 在出现的Web Services对象框,在Service implementation中点击"Browse",进入Browse Classes对象框,查找到我们刚才写的写的CalculateService类。(如下图)。点击"ok",则回到 Web Service话框。 在Web Service对话框中,将Web Service type中的滑块,调到"start service“的位置,将Client type中的滑块调到"Test client"的位置。 在Web Service type滑块图的右边有个"Configuration",点击它下面的选项,进入Service Deployment Configuration对象框,在这里选择相应的Server(我这里用Tomcat6.0)和Web Service runtime(选择Apache Axis2) 点OK后,则返回到Web Service对话框,同理,Client type中的滑块右边也有"Configuration",也要进行相应的置,步骤同上。完成后,Next --> next即行。到了Server startup对话框,有个按键"start server",点击它,则可启动Tomcat服务器了。 等启完后,点击"next -- > next",一切默认即行,最后,点击完成。最后,出现如下界面:(Web Service Explorer),我们在这里便可测试我们的Web服务。 测试比较简单,例如,我们选择一个"plus"的Operation,出现下图,在x的输入框中输入2,在y的 输入框中输入3,点击"go",便会在status栏中显示结果5.0。其他方法的测试也类似。 参考技术A 根据虚拟机提示的异常信息进行错误分析并处理 参考技术B 报错信息为:
AxisFault
faultCode: http://schemas.xmlsoap.org/soap/envelope/Server.userException
faultSubcode:
faultString: java.net.ConnectException: Connection refused: connect
faultActor:
faultNode:
faultDetail:
http://xml.apache.org/axis/stackTrace:java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:516)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.sendServer.TongdaoWs.invokeWg(TongdaoWs.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)

axis自动生成的wsdl文件是有问题的,在他的wddlsoap标签中会使用localhost作为访问地址,
<wsdlsoap:address location="http://localhost:8080/Axis/services/Test"/>
这样当然是只有本机访问正常,其他机器访问不了,解决办法就是修改一下这个地址,比如的地址是10.154.23.153,那么就把这里改为:
<wsdlsoap:address location="http://10.154.23.153:8080/Axis/services/Test"/>
这样,问题就解决了。本回答被提问者采纳

以上是关于如何解决java axis 调用webservice服务器操作异常的主要内容,如果未能解决你的问题,请参考以下文章

Java发布webservice应用并发送SOAP请求调用

Java:用axis调用webservice方法时报(400)Bad Request错,请高手帮忙解决下,错误信息如下

基于Axis1.4的webservice接口开发(接口调用)

java如何通过eclipse安装axis2来调用webservice

如何在调用webserver的时候直接返回一个json的数据

java中使用axis发布和调用webService