axis1 客户端调用需要一个调用类,四个jar包,如果web调用需要配置CLASSPATH=.;D:\Program Files\apache-tomcat-6.0.20\lib\axis-1.4.jar;D:\Program Files\apache-tomcat-6.0.20\lib\jaxrpc.jar 和JAVA_HOME
package com.chinafung.client;
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
/**
* axis1 客户端方式调用webservice
*/
public class CopyOfAxisClient {
private String wdl="http://localhost:8080/GoodsWebService/services/goodsService";
private static Service service;
private Call call;
public static synchronized Service getService()
{
if(service==null)
service=new Service();
return service;
}
public Call getCall()
{
try
{
call=(Call)getService().createCall();
call.setTargetEndpointAddress(new java.net.URL(this.wdl));
call.setOperationName(new QName("http://www.chinafung.com", "ordersService"));
call.setPassword("123");
call.setUsername("123");
return call;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
return null;
}
public void process()
{
try
{
String str="{\"type\":\"success\"}";
getCall().invoke(new Object[]{str});
} catch (RemoteException e) {
e.printStackTrace();
}
}
public static void main(String args[])
{
CopyOfAxisClient ac=new CopyOfAxisClient();
ac.process();
}
}
axis1 客户端开发
最新推荐文章于 2021-12-02 14:58:45 发布