当前位置 : 主页 > 网页制作 > Nodejs >

利用axis请求webservice接口

来源:互联网 收集:自由互联 发布时间:2021-06-24
jar包 aixs.jar import org.apache.axis.AxisProperties; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; String examId = map.get("EXEAM_ID").toString(); String chnlId = login

jar包 aixs.jar

import org.apache.axis.AxisProperties;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;



String examId = map.get("EXEAM_ID").toString();
String chnlId = loginUser.getChnlCode();
String mobileNo = loginUser.getPhone();

//设置代理
AxisProperties.setProperty("http.proxyHost", "ccc.com.net");
AxisProperties.setProperty("http.proxyPort", "8081");


Service service = new Service();
String service_url = "http://xx.com/webservice/examinfo.asmx?wsdl";
String targetNameSpace = "http://tempuri.org/";
Call call = (Call)service.createCall();


call.setTargetEndpointAddress(new java.net.URL(service_url));
call.setOperationName(new QName(targetNameSpace,"GetExamStatus"));

//设置参数
call.addParameter(new QName(targetNameSpace,"ExamId"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(targetNameSpace,"chnlId"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName(targetNameSpace,"mobileNo"), XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);

//设置返回类型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING); 

call.setUseSOAPAction(true);  call.setSOAPActionURI(targetNameSpace+"GetExamStatus"); //返回信息:0(考生不存在) 1(已考) 2(未考) 3(超期未考) String result = call.invoke(new Object[]{ examId,chnlId,mobileNo}).toString();

网友评论