首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

webservice发布没有关问题 调用时axisfault:java.net.ConnectException: Connection refused: co

2012-01-01 
webservice发布没问题 调用时axisfault:java.net.ConnectException: Connection refused: conn这个问题几

webservice发布没问题 调用时axisfault:java.net.ConnectException: Connection refused: conn
这个问题几天了,麻烦高手们帮我看下,非常感谢!
问题描述:
我的webservice用的是Axis 1.0,架设的时候,就是把Axis文件夹放到相应的tomcat安装目录的webapps目录下。
1.修改了tomcat的server.xml文件,将webservice服务器端项目路径部署到了tomcat里面,部分代码如下:

XML code
 <Connector port="8080" protocol="HTTP/1.1"                connectionTimeout="20000"                redirectPort="8443" /> <Host name="localhost"  appBase="webapps"            unpackWARs="true" autoDeploy="true"            xmlValidation="false" xmlNamespaceAware="false">            <Context displayName="tjsoft Struts Application" docBase="E:\wllWorkspace\tdServer\public_html" path="" reloadable="true"></Context>


2.webservice里面的server-config.wsdd文件是我自己加上的,不是它自动生成的,因为每次按照网上的方法生成都不成功,部分代码如下:
XML code
<service name="TongdaoWs" provider="java:RPC"><parameter name="className" value="com.sendServer.TongdaoWs"/><parameter name="allowedMethods" value="*"/></service>


3.启动tomcat,访问我发布的webservice:
http://192.168.1.136:8080/Axis/services/TongdaoWs
可以成功。(不能上图,我把访问出来的页面发在下面,但是有个小问题,问题1:为什么这样访问,不能显示我发布在TongdaoWs的里面的方法,而要在访问的url后面加上?wsdl才能看到里面的方法,还是本来就是这样的?)

TongdaoWs
Hi there, this is an AXIS service!

Perhaps there will be a form for invoking the service here... 

4.客户端调用我发布的webservice,部分代码如下(调用时,需要传递一个mianid参数进去,测试过,这个mainid在程序中是可以获取的):
Java code
public void invokeTd(String mainid){        try {         String url = "http://192.168.1.136:8080/Axis/services/TongdaoWs";        Service serv = new Service();        Call call = (Call) serv.createCall();        call.setTargetEndpointAddress(url);                  System.out.println("1");        call.setOperationName(new QName(url, "invokeWg"));                  System.out.println("2");        call.invoke(new Object[] { mainid });        System.out.println("3");        //call.setOperationName(new QName(url, "Test"));        //System.out.println("4");        System.out.println("通道成功!!");        }        catch (ServiceException e) {        e.printStackTrace();        }         catch (RemoteException e) {        e.printStackTrace();        }        catch (Exception e) {        e.printStackTrace();        }        }


如上:
运行出来的结果是:
1
2

3和“通道成功!!”都没有打印出来,说明那个传mainid的地方根本就没有执行,但是也不报错,但是mainid打印出来过,是有值的。所以我怀疑是传递参数的问题,于是做了另外一个实验,还是上面的代码,在webservice服务器端又写了一个不传参数的最简单的Test方法,就是上面被注释掉的。Test方法会打印一句话"通道是好的!!!!只是不能传参数"。
现在假定把上面代码的
System.out.println("1");
call.setOperationName(new QName(url, "invokeWg"));
System.out.println("2");
call.invoke(new Object[] { mainid });
这4句话(也就是调用invokeWg(String mainid))的这个方法注释掉了,客户端只调用无参的,可以打印语句的Test()方法,输出结果是:
3
4
通道成功!!

这个结果很让人纠结,因为它可以打印出
4
通道成功!!
就说明它执行到了调用Test()方法后面,上面如果调用那个传参的invokeWg方法,这个后面的语句都是不会执行的。但是这里既然执行了,为什么打印不出Test里面要打印的语句呢?

现在就是调用的问题了,在同事的电脑上调用我的webservice,报错如下:
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)



{http://xml.apache.org/axis/}hostname:LEJER0FQOX6AT6H



[解决办法]
友情帮顶...
[解决办法]
错误是连接失败
[解决办法]
不知道你怎么弄的,可以参考http://download.csdn.net/detail/fufengrui/3671377,配置一下

热点排行