Axis1.4 調用 Asp.Net 服務簡單樣本

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   使用   ar   java   

  axis全稱Apache EXtensible Interaction System.版本很多,axis1.x版本最終版是 1.4,之後就到了axis2.x;由於2.x 版本與 1.x版本使用起來的差異比較大(當然2.x版本相對來說會高效很多)。

  這裡以訪問QQ號碼狀態為例,webservice地址:http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl ,在瀏覽器中訪問可看到相關的要求標頭資訊、函數名稱、參數等。

  Java項目中需要用到的Jar包(放在lib目錄下):
  

  需要引用的類:
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ServiceException;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;

  最後是調用代碼:

 1         try { 2          3             String endpoint = "http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl";  4  5             //建立一個服務(service)調用(call)  6             Service service = new Service();  7             Call call = (Call) service.createCall(); 8              9             //設定service所在的url 10             call.setTargetEndpointAddress(new java.net.URL(endpoint)); 11             12             //介面函數13             call.setOperationName(new QName("http://WebXml.com.cn/","qqCheckOnline"));  14             call.setSOAPActionURI("http://WebXml.com.cn/qqCheckOnline");15             16             //介面的參數17             call.addParameter(new QName("http://WebXml.com.cn/","qqCode"), org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);18             19             //設定傳回型別20             call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING); 21             22             String ret = (String)call.invoke(new Object[]{"997717740"}); 23             24             System.out.println("狀態:"+ret);25         26         }27         28         catch(Exception e) {29             BeanCtx.p(e.toString());30         }

 

  

  

Axis1.4 調用 Asp.Net 服務簡單樣本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.