axis1 客戶端開發

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();
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章