我正在尝试使用 ksoap2 从 Android 访问 Web 服务。从我的 android 模拟器发送的肥皂请求就像,
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<Login xmlns="http://xxx.com/" id="o0" c:root="1">
<MyLoginCredentials i:type="d:anyType">
<Email i:type="d:string">asdf@asd.com</Email>
<Password i:type="d:string">asdf</Password>
</MyLoginCredentials>
</Login>
</v:Body>
</v:Envelope>
但是从 SoapUI 表单中,成功的登录请求就像,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:str="http://xxx.com/">
<soapenv:Header/>
<soapenv:Body>
<str:Login>
<str:MyLoginCredentials>
<str:Email>asdf@asd.com</str:Email>
<str:Password>asdf</str:Password>
</str:MyLoginCredentials>
</str:Login>
</soapenv:Body>
</soapenv:Envelope>
这是我的android代码部分:
String NAMESPACE = "http://xxx.com/";
String METHOD_NAME = "Login";
String SOAP_ACTION = "http://xxx.com/Login";
String URL = "http://xxx.tk/service.asmx?wsdl";
Object results;
System.setProperty("http.keepAlive", "false");
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("MyLoginCredentials", myLoginCredentials);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
String Str = null;
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
}
catch(Exception e)
{
e.printStackTrace();
}
请帮我解决问题。谢谢..