android - 是否可以从 android 调用 WSHTTPBINDING?

标签 android .net web-services wcf-wshttpbinding soap1.2

private static final String SOAP_ACTION = "http://tempuri.org/IService1/HelloTest";
private static final String METHOD_NAME = "HelloTest";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "";  //blank for privacy
 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
              //request.addProperty("Celsius", "32");    
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet=true;
                envelope.setOutputSoapObject(request);
                HttpTransportSE ht = new HttpTransportSE(URL);                  
         try {
                ht.call(SOAP_ACTION, envelope);  
                final  SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
                final String str = response.toString();
                Toast.makeText(MainActivity.this, str, 5000).show();
                fetch_service.setText(str);     
             }
         catch (Exception e) {
                   e.printStackTrace();  
             }

我想调用我的方法(Hello Test)。结果将是 hello test 返回。但此示例适用于基本 http 绑定(bind),但不适用于 wshttpbinding。

最佳答案

    Element e = new Element();
        e.setName("To");
        e.setNamespace("http://www.w3.org/2005/08/addressing");
        e.addChild(Node.TEXT,
                "your URL HERE");


        Element e1 = new Element();
        e1.setName("Action");
        e1.setNamespace("http://www.w3.org/2005/08/addressing");
        e1.addChild(Node.TEXT,
                "http://tempuri.org/IService1/HelloTest");

    request.addProperty("Celsius", "32");    

    // use VER12 instead of VER11
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);

    envelope.dotNet=true;

    // add HederOut to envelope
    envelope.headerOut = new Element[] { e, e1 };

    envelope.setOutputSoapObject(request);

关于android - 是否可以从 android 调用 WSHTTPBINDING?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13599013/

相关文章:

android - 我的 Android 应用出现 "Trouble Processing"错误

java - 用垂直线和水平线/ View 划分屏幕

android - 如何将jar文件添加到构建路径

asp.net - WCF 服务绑定(bind)设置

asp.net - ASP.NET Web 服务技术比较

java - 垃圾邮件按钮可播放声音

c# - 在 C# 中通过钩子(Hook)重定向 keydown?

c# - 拦截 Controller

.net - 在WPF中使用OpenFileDialog时没有文件的文件夹路径?

iphone - iPhone 中的 JSON Webservice 问题?