将 Android 应用程序连接到 .net .asmx
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 - 错误代码:'soap:Server' 错误字符串:'System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.InvalidOperationException:输入消息不符合简单 SOAP 绑定配置文件版本 1.0。要求 R1012:消息必须使用 UTF-8 或 UTF-16 字符编码序列化信封。
我尝试过(但没有成功):
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
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)
{
}
Error: SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Input message does not conform to Simple SOAP Binding Profile Version 1.0. Requirement R1012: A MESSAGE MUST serialize the envelope using either UTF-8 or UTF-16 character encoding.
I Tried (and didn't work):
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 ksoap2 从 2.1.2 更新到 2.6.0 解决了该问题。
Updated ksoap2 from 2.1.2 to 2.6.0 solved the problem.