導航:首頁 > 配伺服器 > 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客戶端如何引用伺服器端的類相關的資料

熱點內容
蘋果商店怎麼更新所有app 瀏覽:34
電影香港加密 瀏覽:595
壓縮機毛細管滴水 瀏覽:850
可視化編程網頁 瀏覽:389
工廠附近租房用什麼app 瀏覽:186
老闆改需求甩鍋程序員 瀏覽:657
樂貓app是什麼平台 瀏覽:922
方舟手游如何修改伺服器後台 瀏覽:815
程序員考試教程 瀏覽:219
文件名修改為文件夾的名字批處理 瀏覽:251
拍照程序員 瀏覽:827
wps怎麼把pdf轉jpg 瀏覽:217
自拍用什麼app做的藝術照 瀏覽:169
h3c無線配置命令 瀏覽:515
linux代碼閱讀工具 瀏覽:160
能夠畫出對稱圖形的是什麼app 瀏覽:424
單片機投票器 瀏覽:467
程序員那麼可愛唱嗎 瀏覽:830
手機誤刪的app怎麼恢復 瀏覽:700
java第三方加密庫 瀏覽:660