packagecom.karros.test;importjava.util.HashMap;importjava.util.Map;importjavax.xml.namespace.QName;importorg.apache.axis.client.Call;importorg.apache.commons.lang.StringUtils;importorg.apache.commons.logging.Log;importorg.apache.commons.logging.LogFactory;public classTestWsdl {protected final Log logger =LogFactory.getLog(getClass());public static void main(String[] args) throwsException {
Map paramMap = new HashMap();
paramMap.put("syncTime", "20200401");
Map resultMap = new HashMap();
TestWsdl aa= newTestWsdl();
resultMap=aa.getWebService(paramMap);
System.out.println(resultMap);
}//@Value("${weixin_sign_url}")//private String endpoint;//#微信签到云平台接口地址//weixin_sign_url=http://10.182.5.173:1111/Service/WXQDService.asmx
public String endpoint = "http://10.182.5.96:102/Service/ORGService.asmx";public Map getWebService(Map paramMap) throwsException {
logger.debug("获取接口开始...");
Map resultMap = new HashMap();
resultMap.put("success", true);try{
String syncTime= (String) paramMap.get("syncTime");if (StringUtils.isBlank(syncTime)) { //20200401
resultMap.put("success", false);returnresultMap;
}else{//创建一个服务(service)调用(call)
org.apache.axis.client.Service service = neworg.apache.axis.client.Service();
Call call= (Call) service.createCall();//通过service创建call对象//设置service所在URL
call.setTargetEndpointAddress(newjava.net.URL(endpoint));
call.setOperationName(new QName("http://tempuri.org/", "GetUserList"));//.net 那边的方法 "http://tempuri.org/"这个也要注意Namespace的地址,不带也会报错
call.addParameter(new QName("http://tempuri.org/", "syncTime"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);
call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING);//返回参数的类型
call.setSOAPActionURI("http://tempuri.org/GetUserList"); //这个也要注意
String userVo = (String) call.invoke(newObject[] { syncTime });if (StringUtils.isBlank(userVo) || StringUtils.equals("[]", userVo)) {
resultMap.put("success", false);
}else{
resultMap.put("userVo", userVo);
}
}
}catch(Exception e) {
resultMap.put("success", false);
logger.error("获取信息异常", e);
}
logger.debug("获取接口结束...");returnresultMap;
}
}
package com.karros.test;
import java.util.HashMap;import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;import org.apache.commons.lang.StringUtils;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;
public class TestWsdl {
protected final Log logger = LogFactory.getLog(getClass());public static void main(String[] args) throws Exception { Map paramMap = new HashMap();paramMap.put("syncTime", "20200401");Map resultMap = new HashMap();TestWsdl aa = new TestWsdl();resultMap= aa.getWebService(paramMap);System.out.println(resultMap);}
//@Value("${weixin_sign_url}")//private String endpoint;// #微信签到云平台接口地址// weixin_sign_url=http://10.182.5.173:1111/Service/WXQDService.asmxpublic String endpoint = "http://10.182.5.96:102/Service/ORGService.asmx";public Map getWebService(Map paramMap) throws Exception {logger.debug("获取接口开始...");Map resultMap = new HashMap();resultMap.put("success", true);try {String syncTime = (String) paramMap.get("syncTime");if (StringUtils.isBlank(syncTime)) {//20200401resultMap.put("success", false);return resultMap;} else {// 创建一个服务(service)调用(call)org.apache.axis.client.Service service = new org.apache.axis.client.Service();Call call = (Call) service.createCall();// 通过service创建call对象// 设置service所在URLcall.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://tempuri.org/", "GetUserList"));// .net 那边的方法 "http://tempuri.org/"这个也要注意Namespace的地址,不带也会报错call.addParameter(new QName("http://tempuri.org/", "syncTime"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING); // 返回参数的类型call.setSOAPActionURI("http://tempuri.org/GetUserList"); // 这个也要注意String userVo = (String) call.invoke(new Object[] { syncTime });if (StringUtils.isBlank(userVo) || StringUtils.equals("[]", userVo)) {resultMap.put("success", false);} else {resultMap.put("userVo", userVo);}}} catch (Exception e) {resultMap.put("success", false);logger.error("获取信息异常", e);}logger.debug("获取接口结束...");return resultMap;}
}