有人可以指导我吗?我对在 android 中使用 KSOAP 完全陌生。以下是我在 XML 中的详细信息。我想在 webservice 中发送详细信息。请告诉我如何添加属性,我在那里做错了什么吗?
<?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>
<CheckLoginWithIPhoneData xmlns="http://tempuri.org/">
<UserName>string</UserName>
<Pin>string</Pin>
<Password>string</Password>
<DeviceID>string</DeviceID>
</CheckLoginWithIPhoneData>
</soap:Body>
</soap:Envelope>
在java代码中我已经这样做了:
public void showdetails()
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("UserName","sometext");
request.addProperty("Pin","sometext");
request.addProperty("Password","sometext");
request.addProperty("DeviceID","sometext");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug=true;
androidHttpTransport.call(SOAP_ACTION1, envelope);
Log.e("RESPONSE",""+androidHttpTransport.responseDump);
SoapObject result = (SoapObject) envelope.bodyIn;
Log.e("result",""+result);
if (result != null)
{
Log.e("val", "" + result.getProperty(0).toString());
}
else
{
Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
我已经在后台调用了该方法。
但是,当我尝试打印 RESPONSE Log.e("RESPONSE",""+androidHttpTransport.responseDump); 时出现以下错误
<?xml version="1.0" encoding="utf-8"?><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><soap:Fault><faultcode>soap:Client</faultcode><faultstring>
System.Web.Services.Protocols.SoapException:服务器无法识别 HTTP 标头 SOAPAction 的值:https ://tempuri.org/CheckLoginWithIPhoneData 。