public static void WSAccountListGetList(){
try {
String endpoint = strUrl+"/WSAccountList.asmx";
// 创建一个服务(service)调用(call)
Service service = new Service();
Call call = (Call) service.createCall();// 通过service创建call对象
// 设置service所在URL
call.setTargetEndpointAddress(new java.net.URL(endpoint));
/*
setSOAPActionURI,是动态调用接口使用,而不需要在java里再生成wsdl文件,再引用
Axis' JAXRPC Dynamic Invocation Interface implementation of the Call interface.
This class should be used to actually invoke the Web Service.
It can be prefilled by a WSDL document (on the constructor to the Service object)
or you can fill in the data yourself. */
call.setSOAPActionURI(" http://tempuri.org/GetList");
call.setOperationName(new QName(" http://tempuri.org/",
"GetList"));
Object o = call.invoke(new Object[]{});
System.out.print(o);
} catch (Exception e) {
e.printStackTrace();
}
}
try {
String endpoint = strUrl+"/WSAccountList.asmx";
// 创建一个服务(service)调用(call)
Service service = new Service();
Call call = (Call) service.createCall();// 通过service创建call对象
// 设置service所在URL
call.setTargetEndpointAddress(new java.net.URL(endpoint));
/*
setSOAPActionURI,是动态调用接口使用,而不需要在java里再生成wsdl文件,再引用
Axis' JAXRPC Dynamic Invocation Interface implementation of the Call interface.
This class should be used to actually invoke the Web Service.
It can be prefilled by a WSDL document (on the constructor to the Service object)
or you can fill in the data yourself. */
call.setSOAPActionURI(" http://tempuri.org/GetList");
call.setOperationName(new QName(" http://tempuri.org/",
"GetList"));
Object o = call.invoke(new Object[]{});
System.out.print(o);
} catch (Exception e) {
e.printStackTrace();
}
}
本文介绍如何利用Axis框架实现远程方法调用,通过创建服务和服务调用对象,设置SOAPActionURI和操作名称,成功获取远程服务返回的数据。
499

被折叠的 条评论
为什么被折叠?



