當前位置:編程學習大全網 - 網站源碼 - java如何調用webservice接口?

java如何調用webservice接口?

Java通過WSDL文件調用webservice。直呼方式如下:

導入Java . util . date;

導入Java . text . date format;

導入org . Apache . axis . client . call;

導入org . Apache . axis . client . service;

導入javax . XML . namespace . qname;

導入Java . lang . integer;

導入javax . XML . RPC . parameter mode;

公共類caClient {

公共靜態void main(String[] args) {

嘗試{

string endpoint = " http://localhost:8080/ca3/services/caSynrochnized?wsdl ";

//直接引用遠程wsdl文件。

//下面都是套路嗎?

Service Service = new Service();

Call Call =(Call)service . create Call();

call.setTargetEndpointAddress(端點);

call . setoperationname(" addUser ");//WSDL中描述的接口名稱

call.addParameter("用戶名",org . Apache . axis . encoding . xmltype . xsd _ DATE,

javax . XML . RPC . parameter mode . in);//接口的參數

call . set returntype(org . Apache . axis . encoding . xmltype . xsd _ STRING);//設置返回類型?

String temp = " tester

String result =(String)call . invoke(新對象[]{ temp });

//將參數傳遞給方法並調用方法。

System.out.println("結果是"+結果);

}

捕捉(異常e) {

system . err . println(e . tostring());

}

}

}

  • 上一篇:MACD 指標在零軸上方形成將死不死的時候出現壹個標記的,請高手幫忙寫個公式。
  • 下一篇:青島新聞app打不開
  • copyright 2024編程學習大全網