本人开发环境为:win7+MyEclipse6.5 +tomcat5.5;
问题:在IE9地址栏输入:http://localhost:8080/axis2/services/listServices 能够看到服务已发布成功,
      本人开始编写客户端调用。WSUrl="http://localhost:8080/axis2/services/WSCount";调用地址按说没错啊。出错:org.apache.axis2.AxisFault: Connection refused: connect
   
      Caused by: java.net.ConnectException: Connection refused: connect
请教?为啥就连接不上呢?

解决方案 »

  1.   


    package com.axis2.test;import javax.xml.namespace.QName;
    import org.apache.axis2.AxisFault;
    import org.apache.axis2.addressing.EndpointReference;
    import org.apache.axis2.client.Options;
    import org.apache.axis2.rpc.client.RPCServiceClient;
    import com.axis2.entity.MyBank;/**
     * 调用axis2的webservice
     * */
    public class TestAxis2 {

    private static TestAxis2 bean = new TestAxis2();
    private String serviceUrl = "http://localhost:8088/bank/services/bankService";// webservice的url
    private String nameSpace = "http://service.bank.com";// webservice的命名空间(其实就是协议和包名的倒写)

    /**
     * @see 调用axis2的webservice
     * @param method 发布方的方法名
     * @param args 方法中的参数列表
     * @return MyBank
     * */
    @SuppressWarnings("unchecked")
    public MyBank useAxis2(String method, Object[] args) {
    MyBank bank = null;
    RPCServiceClient client=null;
    try {
    client = new RPCServiceClient();
    Options option = client.getOptions();
    EndpointReference erf = new EndpointReference(serviceUrl);
    option.setTo(erf);
    QName name = new QName(nameSpace, method);
    Class[] returnTypes = new Class[] { MyBank.class };
    Object[] response = client.invokeBlocking(name, args, returnTypes);
    bank = (MyBank) response[0];
    } catch (Exception e) {
    e.printStackTrace();
    }finally{
    try {
    client.cleanupTransport();
    } catch (AxisFault e) {
    e.printStackTrace();
    }
    }
    return bank;
    } public static void main(String[] args) {
    MyBank fromBack = new MyBank();
    MyBank toBank = new MyBank();
    MyBank bank = bean.useAxis2("transition", new Object[]{ fromBack, toBank });
    System.out.println(bank.getPrompt());
    }

    }
      

  2.   

    实测,
    在http://localhost:8088/bank/services/bankService?wsdl这个url能在浏览器访问的时候,
    以上代码运行起来是没有问题的,