Webservice 访问 随笔记载
发布时间:2020-12-16 23:13:14 所属栏目:安全 来源:网络整理
导读:// logInfo 为例 ,实现KvmSerializable 接口, // Webservice 连接 private SoapObject posted(LogInfo info) { SoapObject request = new SoapObject(NameSapce,PostedMethod); PropertyInfo argument = new PropertyInfo(); argument.setName("postLog");
// logInfo 为例 ,实现KvmSerializable 接口, // Webservice 连接 private SoapObject posted(LogInfo info) { SoapObject request = new SoapObject(NameSapce,PostedMethod);PropertyInfo argument = new PropertyInfo(); argument.setName("postLog"); //对应参数名称? argument.setValue(info); argument.setType(LogInfo.class); request.addProperty(argument); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11); HttpTransportSE ht = new HttpTransportSE(Constant.webServiceAddress2); envelope.addMapping(LogInfo.NAMESPACE,"logInfo",LogInfo.class); ?// 第一个参数为命名空间,第二个为类型,与wsdl中的相同 envelope.dotNet = true; envelope.bodyOut = ht; envelope.setOutputSoapObject(request); ht.debug = true; try { ht.call(NameSapce + PostedMethod,envelope); System.out.println("posted-------------->" + ht.requestDump); SoapObject message = (SoapObject) envelope.getResponse(); return message; } catch (HttpResponseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (XmlPullParserException e) { e.printStackTrace(); } return null; } // 服务器 <?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> <PostLog xmlns="http://tempuri.org/"> <postLog> ------- 参数名称 <PostedUser>string</PostedUser> <EventID>string</EventID> <Desc>string</Desc> <Pic>string</Pic> <P1>string</P1> <P2>string</P2> <P3>string</P3> <C1>string</C1> <C2>string</C2> <T1>string</T1> <T2>string</T2> <M1>string</M1> <Treatment>string</Treatment> <DateRepair1>string</DateRepair1> <DateRepair2>string</DateRepair2> </postLog> </PostLog> </soap:Body> </soap:Envelope>
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |