【问题标题】:Is it possible to call WSHTTPBINDING from android?是否可以从android调用WSHTTPBINDING?
【发布时间】:2012-11-28 06:21:36
【问题描述】:
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 测试返回。但此示例适用于基本的 http 绑定,但不适用于 wshttpbinding。

【问题讨论】:

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


    【解决方案1】:
        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);
    

    【讨论】:

    • 我终于从@Tarsem 找到了有价值的答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-21
    相关资源
    最近更新 更多