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

熱點內容
如何創新我的世界伺服器 瀏覽:881
戰地怎麼看伺服器地址 瀏覽:348
vue怎麼打包放上伺服器 瀏覽:165
為什麼安卓服夏日活動沒有兔子頭 瀏覽:894
pubg為什麼顯示伺服器連接失敗 瀏覽:650
阿里雲掃碼登錄伺服器 瀏覽:971
化學基礎pdf 瀏覽:896
51單片機晶碼管 瀏覽:281
怎麼查伺服器假死原因日誌在哪看 瀏覽:277
掃描pdf文件 瀏覽:926
解壓密碼百度雲在線解壓 瀏覽:767
傳播學演算法推薦 瀏覽:749
我的世界網路游戲如何查找伺服器 瀏覽:257
安卓和蘋果通訊錄怎麼互傳 瀏覽:203
怎麼打開隱私與應用加密的菜單 瀏覽:416
我的世界伺服器小游戲的地址大全 瀏覽:578
在網路安全中加密安全機制提供了數據的 瀏覽:249
南京前端程序員私活怎麼收費 瀏覽:981
拓撲pdf 瀏覽:440
如何在工行app查我的訂單 瀏覽:214