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();
本文档演示了如何通过Apache Axis库的jar包axis.jar来调用WebService接口。首先设置了HTTP代理,然后创建Service对象,并指定WebService的URL和服务命名空间。接着创建Call对象并设置操作名称、输入参数和返回类型。最后,调用invoke方法获取返回结果。

3万+

被折叠的 条评论
为什么被折叠?



