我正在尝试使用SOAP 2.4来验证使用Android的用户名和密码。我得到了服务器的响应,我可以确认这是因为MySQL服务器确认我的应用程序提出了请求。但是如下所示,我使用addProperty()方法传递两个参数。 MySQL服务器查看请求,但值为null。结果,我得到一个回复说“无效的用户名或密码”,但我硬编码的用户名和密码绝对是在数据库中。我绝对正确地传递参数吗?
else {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set
// up
// request
request.addProperty("User", "raji"); // variable name, value. I got
// the variable name, from
// the wsdl file!
request.addProperty("Password", "PASSWORD");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11); // put all required data into a soap
// envelope
envelope.setOutputSoapObject(request); // prepare request
AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope); // send request
SoapObject result = (SoapObject) envelope.getResponse(); System.out.println(result);
}
这是SOAP XML文件
<s:element name="ValidateUser">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="User" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
答案 0 :(得分:0)
解决方案代码在这里。我没有添加.net代码
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // set
request.addProperty("User", sUserName); // variable name, value. I
// got
request.addProperty("Password", sPassword);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11); // put all required data into a soap
// envelope
envelope.dotNet = true;
envelope.setOutputSoapObject(request); // prepare request
AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope); // send request
System.out.println("HERE IS THE ENVELOPE "
+ envelope.getInfo("User", "Password"));
SoapObject result = (SoapObject) envelope.getResponse();