标签:test ESS service cat object stat url col script
package com.montnets.emp.sysuser.biz; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName; import javax.xml.rpc.encoding.XMLType; /** * @Description TODO * @Author lensener * Date 2019/3/25 0025 上午 9:14 */ public class TestWebService { public static void main(String[] args) throws Exception { String url = "http://*:*/MWGate/wmgw.asmx";// 提供接口的地址 String soapaction = "http://tempuri.org/"; // 域名,这是在server定义的--不知道的可以问接口提供方,他们一并提供这个 String userId = "TEST06"; String password = "123456"; Service service = new Service(); try{ Call call = (Call) service.createCall(); call.setTargetEndpointAddress(url); call.setOperationName(new QName(soapaction, "hello")); // 设置要调用哪个方法 call.addParameter(new QName(soapaction, "userId"), // 设置要传递的参数--要和接口方提供的参数名一致 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(soapaction, "password"), // 设置要传递的参数 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.SOAP_STRING); // 要返回的数据类型 call.setUseSOAPAction(true); //call.setSOAPActionURI(soapaction + "hello"); String v = (String) call.invoke(new Object[] { userId, password });// 调用方法并传递参数-传递的参数和设置的参数要对应,顺序不能搞错了 System.out.print(v);//打印结果(我设置的接收格式为json字符串,这边直接打印出来) }catch (Exception ex){ ex.printStackTrace(); } } }
标签:test ESS service cat object stat url col script
原文地址:https://www.cnblogs.com/lensener/p/10592211.html