CNDS15842451650
yeqiiii
采纳率0%
2016-08-20 10:36

基于AXIS调用webservice报错:Connection refused: connect

10

我的调用方法:
public static void main(String[] args) throws Exception {
String client_id = "HeYiApp";
String orderNum = "2";
List numberList = new ArrayList();
numberList.add("120719");
numberList.add("120746");
numberList.add("113095");
String webUrl = "https://10.218.132.26/api/openapi/employee/getBatchEmpInfoList.json";// 服务端url地址
String webMethod = "getBatchEmpInfoList";// 调用方法名称
Service service = new Service(); // 建服务
Call call;
try {
call = (Call) service.createCall();
try {
call.setTargetEndpointAddress(new URL(webUrl));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}// 设置访问地址
call.setOperationName(webMethod);// 设置访问方法
call.addParameter("arg0", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);// 定义参数
call.addParameter("arg1", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);// 定义参数
call.addParameter("arg2", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);// 定义参数
call.setReturnType(XMLType.XSD_STRING);// 定义返回值格式
//List> workersInfo= (List>) call.invoke(new Object[] { client_id, numberList, orderNum });
//for(Map m:workersInfo){
// System.out.println(m.get("name"));
//}
JSONArray jsonObject = (JSONArray) call.invoke(new Object[] { client_id, numberList, orderNum });
System.out.println(jsonObject.toString());
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} // 建对话

}

报错:

Exception in thread "main" 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.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:427)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
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 webservice.Test.main(Test.java:52)

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

java.net.ConnectException: Connection refused: connect
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
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 webservice.Test.main(Test.java:52)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at sun.security.ssl.SSLSocketImpl.(SSLSocketImpl.java:427)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
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)
... 10 more

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • Focus focusnothing 5年前

    确定webservice服务运行是正常的?
    有没有官方的测试工具和方法?

    点赞 评论 复制链接分享
  • CNDS15842451650 yeqiiii 5年前

    这是我调用的方法:
    public static void main(String[] args) throws Exception {
    String client_id = "HeYiApp";
    String orderNum = "2";
    List numberList = new ArrayList();
    numberList.add("120719");
    numberList.add("120746");
    numberList.add("113095");
    String webUrl = "https://10.218.132.26/api/openapi/employee/getBatchEmpInfoList.json";// 服务端url地址
    String webMethod = "getBatchEmpInfoList";// 调用方法名称
    Service service = new Service(); // 建服务
    Call call;
    try {
    call = (Call) service.createCall();
    try {
    call.setTargetEndpointAddress(new URL(webUrl));
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }// 设置访问地址
    call.setOperationName(webMethod);// 设置访问方法
    call.addParameter("arg0", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);// 定义参数
    call.addParameter("arg1", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);// 定义参数
    call.addParameter("arg2", XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);// 定义参数
    call.setReturnType(XMLType.XSD_STRING);// 定义返回值格式
    //List> workersInfo= (List>) call.invoke(new Object[] { client_id, numberList, orderNum });
    //for(Map m:workersInfo){
    // System.out.println(m.get("name"));
    //}
    JSONArray jsonObject = (JSONArray) call.invoke(new Object[] { client_id, numberList, orderNum });
    System.out.println(jsonObject.toString());
    } catch (ServiceException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } // 建对话

    }
    
    点赞 评论 复制链接分享