關於使用axis調用webservice接口方法


1、概述:

  我們有時候會調用webserviec接口,我們向接口發送請求參數,從接口接收返回值。

2、形式:

  

package client;  
  
import org.apache.axis.client.Call;  
import org.apache.axis.client.Service;  
  
public class TestClient {  
  
    public static void main(String[] args) throws Exception {  
  
        // 指出service所在URL       
  
        String endpoint = "http://xxxxxxxxxxxxxx/webservice/services/xxxxxxxxx";  
  
        // 創建一個服務(service)調用(call)       
  
        Service service = new Service();  
  
        Call call = (Call) service.createCall();// 通過service創建call對象       
  
        // 設置service所在URL       
  
        call.setTargetEndpointAddress(new java.net.URL(endpoint));  
  
        // 方法名(processService)與MyService.java方法名保持一致       
  
        call.setOperationName("getName");  
  
        // Object 數組封裝了參數,參數為"This is Test!",調用processService(String arg)       
  
        String ret = (String) call.invoke(new Object[] { "xxxxx" });  
  
        System.out.println(ret);  
  
    }  
  
}  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM