private static final String NAMESPACE = "http://tempuri.org/" ;
private static final String URL = "http://mydomain.com/test.asmx";
private static final String PingSA = "http://tempuri.org/Ping";
private static final String PingMN = "Ping";
SoapObject request = new SoapObject(NAMESPACE, PingMN);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(PingSA, envelope);
Object x = envelope.getResponse();
}
catch(Exception e)
{
}
错误:SoapFault - faultcode:' soap:Server' faultstring:' System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.InvalidOperationException:输入消息不符合Simple SOAP Binding Profile Version 1.0。要求R1012:消息必须使用UTF-8或UTF-16字符编码序列化信封。
我试过(并且没有工作):
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
答案 0 :(得分:0)
从2.1.2到2.6.0更新了ksoap2解决了这个问题。