我正在尝试使用ksoap2调用我的服务。在我的请求中,我想添加我自己的xml 来请求我该怎么做?我用google搜索,我看到一些与PropertyInfo有关的示例但我不这样做明白了。请帮帮我
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
> /*PropertyInfo p = new PropertyInfo();
> p.setName(METHOD_NAME);
> p.setValue(getLoyaltyMember(URL,METHOD_NAME,"T111","3122100193697","3121002193697"));
> p.setType(Boolean.class);
> request.addProperty(p); Iam not sure here*//
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
String sd = resultsRequestSOAP.toString();
String test = sd;
} catch (Exception e) {
e.printStackTrace();
}
//我自己的请求我想添加肥皂请求
**public String getLoyaltyMember(String URL, String Method,
String UserSessionId,String MemberPassword,String MemberLogin) {
SOAPRequestXMLBody=
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"http://hello.com.tr/services/WSHelloWebClient.DataTypes/1/\">"
+ "<SOAP-ENV:Body>"
+"<ns1:ValidateMemberRequest>"
+"<ns1:UserSessionId>"+UserSessionId+"</ns1:UserSessionId>"
+"<ns1:MemberPassword>"+MemberPassword+"</ns1:MemberPassword>"
+"<ns1:MemberLogin>"+MemberLogin+"</ns1:MemberLogin>"
+"<ns1:ReturnMember>true</ns1:ReturnMember>"
+"<ns1:MemberId>?</ns1:MemberId>"
+"<ns1:MemberCardNumber>?</ns1:MemberCardNumber>"
+"<ns1:MemberEmail>?</ns1:MemberEmail>"
+"<ns1:ClubId>?</ns1:ClubId>"
+"<ns1:IncludeAdvanceBooking>true</ns1:IncludeAdvanceBooking>"
+" </ns1:ValidateMemberRequest>"
+" </SOAP-ENV:Body>"
+"</SOAP-ENV:Envelope>";
return SOAPRequestXMLBody;
}**
编辑:
I must add my own xml. Because my other request like this
SOAPRequestXMLBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
+ "<soap:Body>"
+ "<AddTicketsRequest xmlns=\"http://hello.com.tr/services/WSHelloWebClientWS.ServiceContracts/1\">"
+ "<OptionalClientClass xmlns=\"http://hello.com.tr/services/WSHelloWebClientWS.DataTypes/1/\"/>"
+ "<OptionalClientId xmlns=\"http://hello.com.tr/services/WSHelloWebClientWS.DataTypes/1\" />"
+ "<OptionalClientName http://hello.com.tr/services/WSHelloWebClientWS.DataTypes/1\" />"
+ "<UserSessionId>"
+ UserSessionId
+ "</UserSessionId>"
答案 0 :(得分:0)
您不需要使用PropertyInfo,虽然没有错,但您可以使用以下数据调用您的网络服务:
request.addProperty("UserSessionId", value1);
request.addProperty("MemberPassword", value2);
request.addProperty("MemberLogin", value3);
request.addProperty("ReturnMember", value4);
request.addProperty("MemberId", value5);
......
此处的value1是您要在UserSessionId中设置的值,value2是将在Web服务中设置为MemberPassword的值,依此类推..
你还应该添加这一行
envelope.dotNet = true;
下面
envelope.setOutputSoapObject(request);
如果您想使用.net webservices
我希望它有所帮助