JAVA使用axis调用.net WSDL的WebService

 
  1. import javax.xml.rpc.ParameterMode;   
  2.   
  3. import org.apache.axis.client.Call;   
  4. import org.apache.axis.client.Service;   
  5. import org.apache.axis.encoding.XMLType;   
  6.   
  7. public class caClient {   
  8.   
  9.     /**  
  10.      * @param args  
  11.      */  
  12.     public static void main(String[] args) {   
  13.         try {   
  14.             String endpoint = "http://ls.cqu.edu.cn/WebService/LibraryInterface.asmx?WSDL";   
  15.             // 直接引用远程的wsdl文件   
  16.             // 以下都是套路   
  17.             Service service = new Service();   
  18.   
  19.             Call call = (Call) service.createCall();   
  20.             call.setTargetEndpointAddress(endpoint);   
  21.             call.setOperationName("SetLibraryValue");// WSDL里面描述的接口名称   
  22.   
  23.             call.setSOAPActionURI("http://ls.cqu.edu.cn/SetLibraryValue");   
  24.             call.addParameter("Key", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  25.             call.addParameter("XH", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  26.             call.addParameter("HJDM", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  27.             call.addParameter("BLSM", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  28.             call.addParameter("SetState", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  29.             call.addParameter("CZRID", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  30.             call.addParameter("LogIP", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数   
  31.   
  32.             call.setReturnType(XMLType.XSD_STRING);// 设置返回类型   
  33.   
  34.             String key = "ewfasdfdsafew23434";   
  35.             String xh = "22";   
  36.             String hjdm = "33";   
  37.             String blsm = "33";   
  38.             String ss = "33";   
  39.             String cid = "33";   
  40.             String ip = "33";   
  41.             String result = (String) call.invoke(new Object[] { key, xh, hjdm, blsm, ss, cid, ip });   
  42.   
  43.             // 给方法传递参数,并且调用方法   
  44.             System.out.println("result is " + result);   
  45.         } catch (Exception e) {   
  46.             System.err.println(e.toString());   
  47.         }   
  48.     }   
  49.   
  50. }  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值