import org.apache.axis.client.Call;
import org.springframework.context.annotation.Configuration;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Configuration
public class RemoteCallSchedule {
public String webserviceCall(String password, String Code, Integer day){
List<Map<String, Object>> storeItemList = new ArrayList<>();
//获取webservice接口地址
String remoteUrl = "http://ip地址:端口号/xxx.asmx";
//获取域名地址,server定义的
String soapaction = "http://tempuri.org/";
//调用的方法名
String method = "调用方法";
// 创建一个服务(service)调用(call)
org.apache.axis.client.Service service = new org.apache.axis.client.Service();
// 创建一个服务(service)调用(call)
Call call = null;// 通过service创建call对象
try {
call = (Call) service.createCall();
} catch (ServiceException e) {
e.printStackTrace();
}
// 设置service所在URL
call.setTargetEndpointAddress(remoteUrl);
call.setOperationName(new QName(soapaction, method));
//设置参数及类型,与接口参数对应
call.addParameter(new QName(soapaction, "参数1"),
org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(soapaction, "参数二"),
org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(soapaction, "参数三"), // 设置要传递的参数
org.apache.axis.encoding.XMLType.XSD_INTEGER,
javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);
// call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_STRING); //返回参数的类型
call.setReturnType(new QName(soapaction,method), String.class); //返回参数的类型
call.setSOAPActionURI(soapaction + method); //这个也要注意 就是要加上要调用的方法getStoreList,不然也会报错
//invoke调用方法并传递参数,获取XML
String invoke = null;
try {
invoke = (String) call.invoke(new Object[]{参数1, 参数二, 参数三});
} catch (RemoteException e) {
e.printStackTrace();
}
return invoke;
}
}