Is it possible to call WSHTTPBINDING from android?

隐身守侯 提交于 2019-12-04 04:48:47

问题


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();  
             }

I want to call my method (Hello Test). The result will be hello test return. But this sample is working for basic http binding but not working for wshttpbinding.


回答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);


来源:https://stackoverflow.com/questions/13599013/is-it-possible-to-call-wshttpbinding-from-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!