我对 ksoap Parsing 有一点了解。当我解析一些数据时,它会给出错误:
java.lang.ClassCastException: org.ksoap2.SoapFault
我可以在SoapUI中看到该方法的响应,但是当我在 android 中解析该方法时,它会出现如上所述的错误。
这是 SoapUI 中作为输入的请求参数
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:SaveChangePasswordForExternalUser>
<tem:userId>Test123</tem:userId>
<!--Optional:-->
<tem:oldPassword>TestTest</tem:oldPassword>
<!--Optional:-->
<tem:newPassword>Test</tem:newPassword>
<!--Optional:-->
<tem:retypedNewPassword>Test</tem:retypedNewPassword>
</tem:SaveChangePasswordForExternalUser>
</soapenv:Body>
</soapenv:Envelope>
这是我在 SoapUI 中得到的响应
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
<faultstring xml:lang="en-US">Old Password was incorrectly entered. Remember that passwords are case-sensitive.</faultstring>
<detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>Old Password was incorrectly entered. Remember that passwords are case-sensitive.</Message>
<Type>System.Web.Services.Protocols.SoapException</Type>
</ExceptionDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
这就是我尝试通过android中的代码获得响应的方式
public void getData()
{
private static final String NAMESPACE = "http://tempuri.org/"; //
private static final String URL = "http://173.203.136.194:99/LeaseWave.MobileApplication.Service/MobileApplicationService.svc/basic";
private static final String SOAP_ACTION = "http://tempuri.org/IMobileApplicationService/SaveChangePasswordForExternalUser";
private static final String METHOD_NAME = "SaveChangePasswordForExternalUser";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("userId", "Test123");
request.addProperty("oldPassword", "TestTest");
request.addProperty("newPassword", "Test");
request.addProperty("newPassword", "Test");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
Log.i("Long...", "Response ------ "+resultsRequestSOAP);
}catch (Exception e)
{
e.printStackTrace();
}
}
但我没有得到成功。有人对此有任何提示或解决方案吗?