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

熱點內容
單片機投票器 瀏覽:467
程序員那麼可愛唱嗎 瀏覽:830
手機誤刪的app怎麼恢復 瀏覽:700
java第三方加密庫 瀏覽:660
編譯代碼軟體哪個好 瀏覽:997
編譯器軟體圖片 瀏覽:880
美團專送app怎麼不接受遠單 瀏覽:833
伺服器mgmt口如何連接電腦 瀏覽:798
做程序員至少要精通幾種 瀏覽:673
個人用雲伺服器價格對比 瀏覽:257
如何遠程刪除伺服器文件夾 瀏覽:779
a9賬號如何移植到安卓 瀏覽:340
gpib介面編程 瀏覽:468
索尼recovery編譯 瀏覽:878
app後端php 瀏覽:625
中獎的app叫什麼名字 瀏覽:92
定時關機命令批處理 瀏覽:941
閃電pdf 瀏覽:642
winform原生編譯 瀏覽:337
同比提升比的演算法 瀏覽:887