赞
踩
对方提供的接口文档
webservice接口地址:http://192.168.0.16/WebService/CityManagerQYSWGnew.asmx
import org.apache.axis.client.Call; import org.apache.axis.encoding.XMLType; import javax.xml.rpc.ParameterMode; import javax.xml.namespace.QName; import org.apache.axis.client.Service; public void callWebserviceASMX() throws IOException { String caseguid = this.getRequestParameter("caseguid"); //获取webservice接口地址 String url = "http://172.20.197.226/WebService/CityManagerQYSWGnew.asmx"; //获取域名地址,server定义的,一般默认是http://tempuri.org/,如果不对,找对方索要 String soapaction = "http://tempuri.org/"; String method = "FNZF_BH_CityManage"; Service service = new Service(); String result = ""; try { Call call = (Call) service.createCall(); call.setTargetEndpointAddress(url); //设置要调用的方法 call.setOperationName(new QName(soapaction, method)); // 设置要传递的参数,字符串用XMLType.XSD_STRING,日期用XMLType.XSD_DATE(根据对方要求) call.addParameter(new QName(soapaction, "caseguid"), XMLType.XSD_STRING, ParameterMode.IN); call.addParameter(new QName(soapaction, "status"), XMLType.XSD_STRING, ParameterMode.IN); call.addParameter(new QName(soapaction, "reason"), XMLType.XSD_STRING, ParameterMode.IN); call.addParameter(new QName(soapaction, "ValidateData"), XMLType.XSD_STRING, ParameterMode.IN); //设置要返回的数据类型(标准的类型) call.setReturnType(XMLType.XSD_STRING); call.setUseSOAPAction(true); call.setSOAPActionURI(soapaction + method); //调用方法并传递参数 result = (String) call.invoke(new Object[]{caseguid, "E", "作废理由", "FNZF_**##"}); System.out.println("result is:::" + result); } catch (Exception e) { e.printStackTrace(); } this.getResponse().getWriter().println(result); }
调用域名及调用方法名是在server端SOAPAction配置
POST /WebService/CityManagerQYSWGnew.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/CityManagerQYSWGnew" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <FNZF_BH_CityManage xmlns="http://tempuri.org/"> <caseguid>string</caseguid> <status>string</status> <reason>string</reason> <ValidateData>string</ValidateData> </FNZF_BH_CityManage> </soap:Body> </soap:Envelope>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。