使用Axis调用WebSerivices非常简单,废话不多说,直接上代码
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
public class ClientCall {
public static void main(String[] args) {
try {
String url = "此处为webServices地址";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
call.setOperationName(new QName(url, "exec"));//exec为要调用的方法名
call.addParameter(new QName("此处为命名空间,为WSDL文件中的targetNamespace地址",
"units"),XMLType.SOAP_STRING,ParameterMode.IN);//这里的units为传入参数的变量名字
call.setReturnType(new QName("此处为命名空间,为WSDL文件中的targetNamespace地址",
"response"), Xljg[].class);//Xlgj[]这里是重点,返回数组时主要在些配置,Xljg为返回的对象
// 注册映射关系
QName XljgInfo = new QName("此处为命名空间,为WSDL文件中的targetNamespace地址", "xljg");//此处的xljg为WSDL文件中complexType name的属性值
call.registerTypeMapping(Xljg.class, XljgInfo,
new BeanSerializerFactory(Xljg.class, XljgInfo),
new BeanDeserializerFactory(Xljg.class, XljgInfo));//Xljg.class同上,这里不需要为数组
Xljg[] xljg = (Xljg[]) call.invoke(new Object[] {"昆明"});//昆明为传入的参数,即上面的units
System.out.println(xljg.length);//打印输出数组
for(Xljg xl : xljg){
System.out.println(xl.getQualifications()+": "+xl.getCount());
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
Xljg类的代码:
public class Xljg {
private String qualifications;
private long count;
public String getQualifications() {
return qualifications;
}
public long getCount() {
return count;
}
}
分享到:
相关推荐
使用Java+Axis2调用Web Services 网络接口,代码中列举4个例子可以查看,有详细注释提供参考。
单位刚好有这么一个项目需要于客户端中调用webServices,整理了下资料发上来希望对大家有用。 axis 1.4 一共是三种方式调用: 1传递参数String,得到String 2传递参数String,得到对象Users 3传递对象Users,得到...
axis 自定义 数组 对象复杂类型的精华所在
本项目是在实际开发调用webservices接口时的做的例子。使用Axis技术开发。 其中包含webservices开发,以及webservices调用。 运行项目后输入:http://localhost:8080/webserviceDemo/services/helloService?wsdl ...
用axis2开发web services 所需jar包
Chapter 1, Apache Web Services and Axis2 - Gives you an introduction to web services and the web service stack at Apache. Chapter 2, Looking inside Axis2 - Learn about Axis2 architecture and the ...
包括3本Axis2的书(英文),實為2本(第1本有关于CXF(前身XFire)的内容為第三本的第三版) 1.Developing Web Services with Apache CXF and Axis2, 3rd Edition 2.Packt.Publishing.Quickstart.Apache.Axis2 3....
Java 中,使用axis来实现webServices 里面包含Word详细说明使用webservices的步骤, 看了就会啦, 使用webServicers里面jar ,和工具都包含在里面。。。 如果你要实现webservies的话, 不看后悔死你。。。。
压缩包中包含详细代码以及所用到的jar,是完整可运行的project。当然,需要正确的路径支持才可以运行,本人没有把我所用到的路径贴出,改为本机地址。
NULL 博文链接:https://conkeyn.iteye.com/blog/1010959
axis调用第三方webservice接口所需的jar包,包括axis-1.4.jar,axis-jaxrpc-1.3.jar,axis-jaxrpc-1.4.jar,commons-discovery-0.5.jar,commons-logging-1.2.jar,cxf-rt-databinding-jaxb-3.3.1.jar,javax.mail-...
在WTP 2中使用Axis 1_4 构建Web Services
本案例实现使用Axis2生成.arr包发布WebService服务,并使用Axis2生成客户端代码方式调用WebService
java axis 调用C# webService所需的jar包
axis2客户端调用axis1服务接口 调用方式 使用RPC方式调用WebService,为了防止冲突可以增加 // 与weblogic的lib冲突配置 System.setProperty("javax.xml.stream.XMLInputFactory", ...
Android 利用axis2 调用webservice 包含j2ee服务端代码和Android客户端代码 代码实现包含 List,map ,对象传递
Axis2集成Spring发布WebServices服务
使用jax-ws 来发布一个webservice,客户端使用 axis2 取得webservices 的数据。一个很好的例子,有返回数组的,有返回LIST。
Extensive and detailed coverage of the enterprise ready Apache Axis2 Web Services / SOAP / WSDL engine. Attain a more flexible and extensible framework with the world class Axis2 architecture. Learn ...
一、Axis的安装 <br/>应用Axis开发Web Services,你需要安装如下软件: 1.JDK1.4.2或以上 2.http://ws.apache.org/axis/dist/1_1/下载得到 3.一个支持Servlet的服务器引擎,比如广为人知的Tomcat。...