web service连接问题

palettezwl 2012-11-02 04:12:14
本人开发环境为: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


请教?为啥就连接不上呢?
...全文
212 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
s478853630 2012-11-02
  • 打赏
  • 举报
回复
实测,
在http://localhost:8088/bank/services/bankService?wsdl这个url能在浏览器访问的时候,
以上代码运行起来是没有问题的,
s478853630 2012-11-02
  • 打赏
  • 举报
回复

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());
}

}

67,516

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧