JAVA 用axis1 調用.NET的web service

1.去官網下載axis的jar包,我下的是1.4版本的html

http://axis.apache.org/axis/java/releases.htmljava

2.JAVA 代碼:apache

public void myWebService() throws Exception {
Service service = new Service();
Call call = null;
try {
call = (Call) service.createCall();
//http://10.107.56.11/test/wsValidateAccount.asmx 是Web Service的URL地址 call.setTargetEndpointAddress(new URL("http://10.107.56.11/test/wsValidateAccount.asmx"));
//http://tempuri.org/ 是Web Service的命名空間,validate 是函數名,下面類同 call.setOperationName(new QName("http://tempuri.org/","validate"));
//添加參數,account是函數的參數名 call.addParameter(new QName("http://tempuri.org/","account"),org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
//添加參數,pwd是函數的參數名 call.addParameter(new QName("http://tempuri.org/","pwd"),org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);

//設置函數返回類型
       call.setReturnType(org.apache.axis.encoding.XMLType.XSD_BOOLEAN);
       call.setUseSOAPAction(true);
        call.setSOAPActionURI("http://tempuri.org/validate"); //給WebService的函數傳參       System.out.println(call.invoke(new Object[]{"數值","數值"})); } catch (Exception e) { e.printStackTrace(); } }
相關文章
相關標籤/搜索