具体调用调用webservice的方法为: (1) 指定webservice的命名空间和调用的方法名,如: SoapObject request =new SoapObject(http://service...,"getName"); SoapObject类的第一个参数表示WebService的命名空间,可以从WSDL文档中找到WebService的命名空间。...在创建SoapSerializationEnvelope对象后,不要忘了设置SOAPSoapSerializationEnvelope类的bodyOut属性,该属性的值就是在第一步创建的SoapObject...(6)使用getResponse方法获得WebService方法的返回结果,代码: SoapObject soapObject =( SoapObject) envelope.getResponse()...result = (SoapObject) envelope.bodyIn; detail = (SoapObject) result .getProperty("getWeatherbyCityNameResult
password.addChild(Node.TEXT, ID_PASSWORD_VALUE); header[0].addChild(Node.ELEMENT, password); // 创建 SoapObject...对象用于传递请求参数 final SoapObject soapObject = new SoapObject(NAMESPACE, methodName); // 添加参数 if (mapParams...header; // 身份验证(如果需要的话) envelope.dotNet = isDotNet; // 设置是否调用的是 .Net 开发的 WebService envelope.bodyOut = soapObject...= null) { // 获取服务器响应返回的 SoapObject SoapObject object = (SoapObject) envelope.bodyIn; result = object.getProperty...= null) { // 获取服务器响应返回的 SoapObject SoapObject object = (SoapObject) envelope.bodyIn; result = object.getProperty
; import org.ksoap2.HeaderProperty; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject...对象 SoapObject soapObject = new SoapObject(NAMESPACE, methodName); // SoapObject添加参数...= null) { // 获取服务器响应返回的SoapObject resultSoapObject =...(SoapObject) soapEnvelope.bodyIn; } } catch (HttpResponseException...soapObject,String retinfo); } } POST /webservice/xxxx.PlatFormWS.asmx HTTP/1.1 User-Agent: ksoap2
://xfire.util.ems.csc.gov"; //要调用的方法名称 String methodName = "showDataInfo"; SoapObject...request = new SoapObject(namespace, methodName); // 设置需调用WebService接口需要传入的参数 request.addProperty...HttpTransportSE(WSDL_URI); //调用 httpTransportSE.call(null, envelope); // 获取返回的数据 SoapObject...object = (SoapObject) envelope.bodyIn; // 获取返回的结果 result = object.getProperty(0).toString
Envelop对象 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);// 实例化SoapObject...对象 SoapObject object = new SoapObject(namespace, methodName); // 设置参数 object.addProperty("arg0", "hhh..."); // 将SoapObject对象设置为SoapSerializationEnvelope对象的传出SOAP消息 envelope.bodyOut = object;//由于是发送请求,所以是设置
webservice端传递过来的对象的解析过程都可以在自身的类里面完成 相当于是一个简单的封装 下面看一下两种简单的调用方法 在第二种需要返回结果的调用方法中,我们一律使用list来返回一个对象类表,把传递过来的soapobject...传递给自己 相对应的自建对象并在内部解析后返回一个对象列表,下面可以看一下一个类的解析,就是把soapobject每个节点的 值拿出来赋给对象的一个字段,并不复杂 三、向webservice端传递复杂数据类型
领取专属 10元无门槛券
手把手带您无忧上云