java 调用 .net webservic

来源:互联网 发布:移动硬盘与mac不兼容 编辑:程序博客网 时间:2024/05/17 23:50
 public static void WSAccountListGetList(){
     try {
   String endpoint = strUrl+"/WSAccountList.asmx";
   // 创建一个服务(service)调用(call)
   Service service = new Service();
   Call call = (Call) service.createCall();// 通过service创建call对象
   // 设置service所在URL
   call.setTargetEndpointAddress(new java.net.URL(endpoint));
   
   /*
    setSOAPActionURI,是动态调用接口使用,而不需要在java里再生成wsdl文件,再引用
          Axis' JAXRPC Dynamic Invocation Interface implementation of the Call interface.
          This class should be used to actually invoke the Web Service.
          It can be prefilled by a WSDL document (on the constructor to the Service object)
            or you can fill in the data yourself. */
   call.setSOAPActionURI("http://tempuri.org/GetList");
   
   call.setOperationName(new QName("http://tempuri.org/",
     "GetList"));
  
   Object o = call.invoke(new Object[]{});
   System.out.print(o);
  } catch (Exception e) {
   e.printStackTrace();
   
  }
    }
原创粉丝点击