- import javax.xml.rpc.ParameterMode;
- import org.apache.axis.client.Call;
- import org.apache.axis.client.Service;
- import org.apache.axis.encoding.XMLType;
- public class caClient {
- /**
- * @param args
- */
- public static void main(String[] args) {
- try {
- String endpoint = "http://ls.cqu.edu.cn/WebService/LibraryInterface.asmx?WSDL";
- // 直接引用远程的wsdl文件
- // 以下都是套路
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(endpoint);
- call.setOperationName("SetLibraryValue");// WSDL里面描述的接口名称
- call.setSOAPActionURI("http://ls.cqu.edu.cn/SetLibraryValue");
- call.addParameter("Key", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.addParameter("XH", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.addParameter("HJDM", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.addParameter("BLSM", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.addParameter("SetState", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.addParameter("CZRID", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.addParameter("LogIP", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
- call.setReturnType(XMLType.XSD_STRING);// 设置返回类型
- String key = "ewfasdfdsafew23434";
- String xh = "22";
- String hjdm = "33";
- String blsm = "33";
- String ss = "33";
- String cid = "33";
- String ip = "33";
- String result = (String) call.invoke(new Object[] { key, xh, hjdm, blsm, ss, cid, ip });
- // 给方法传递参数,并且调用方法
- System.out.println("result is " + result);
- } catch (Exception e) {
- System.err.println(e.toString());
- }
- }
- }
JAVA使用axis调用.net WSDL的WebService
最新推荐文章于 2021-02-20 07:58:14 发布