将 Android 应用程序连接到 .net .asmx

发布于 2024-12-27 04:06:12 字数 1152 浏览 0 评论 0原文

 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫南 2025-01-03 04:06:12

将 ksoap2 从 2.1.2 更新到 2.6.0 解决了该问题。

Updated ksoap2 from 2.1.2 to 2.6.0 solved the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文