導航:首頁 > 配伺服器 > axis客戶端如何引用伺服器端的類

axis客戶端如何引用伺服器端的類

發布時間:2024-05-30 04:48:17

java怎麼使用axis調用webservice

方式一:生成客戶端代碼調用方式。
通過插件工具生成客戶端代碼進行調用。例如:存在一服務為 http://127.0.0.1:8000/axis2/services/SMSSendService?wsdl通過插件可以生成SMSSendServiceStub.Java和SMSSendServiceCallbackHandler.java類。調用的客戶端代碼如:

try {

SMSSendServiceStub stub=new SMSSendServiceStub();

SMSSendServiceStub.method1 m1=new SMSSendServiceStub.method1();
m1.setParam1("xxx");

try {
String ret=stub.multiSend(m1).get_return();
System.out.print(ret);
} catch (RemoteException e) {
e.printStackTrace();
}
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
方式二:使用axis2.rpc.client.RPCServiceClient方式調用。

調用的代碼簡單舉例如下:

import org.apache.axis2.addressing.EndpointReference;

import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
......

try {

final String endpoint = "http://127.0.0.1:8000/axis2/services/SMSSendService";
String opName = "method1";
String param="xxx";
Object[] opArgs = new Object[] { param };
Class<?>[] opReturnType = new Class[] { String[].class };

RPCServiceClient serviceClient = new RPCServiceClient();//此處RPCServiceClient 對象實例建議定義成類中的static變數,否則多次調用會出現連接超時的錯誤。

Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference(endpoint);
options.setTo(targetEPR);
QName opQName = new QName("http://service.ws.sms.ipcc.ydtf.com",
opName);
Object[] ret = serviceClient.invokeBlocking(opQName, opArgs,
opReturnType);
System.out.println(((String[]) ret[0])[0]);
} catch (AxisFault e) {
e.printStackTrace();
}

閱讀全文

與axis客戶端如何引用伺服器端的類相關的資料

熱點內容
pdf的字體怎麼改 瀏覽:856
python讀寫視頻 瀏覽:88
科魯茲壓縮機軸承 瀏覽:353
word文檔轉換成pdf文件找不到 瀏覽:27
組件注冊命令 瀏覽:760
安卓大屏導航用的是什麼運放 瀏覽:443
myandroidtools的備份 瀏覽:900
python爬蟲天氣預報 瀏覽:761
android70許可權管理 瀏覽:749
魔獸辛迪加是什麼伺服器 瀏覽:471
電腦文件夾排序怎麼自定義排序 瀏覽:41
android70機型 瀏覽:422
阿里程序員地位 瀏覽:183
js如何上傳大文件到伺服器地址 瀏覽:685
安卓系統2個卡怎麼切換 瀏覽:182
vivoy9s手機怎麼設置隱私相冊加密 瀏覽:158
android載入網路數據 瀏覽:119
tc語言入門編程 瀏覽:339
載入器app源碼大全 瀏覽:821
linux刷新hosts 瀏覽:620