How to query a web service via POST request in Android?

前端 未结 2 1291
半阙折子戏
半阙折子戏 2020-12-02 01:39

I am totally new to Web Feature Service (WFS) but I want to build an Android application with ksoap2-android on top of an API publishing its data via WFS. I would like to re

2条回答
  •  盖世英雄少女心
    2020-12-02 01:54

    Normally, and from what little experience I have with ksoap2, you would do something like this.

    SoapObject request = new SoapObject("http://www.webserviceX.NET", "GetCitiesByCountry");
    String soapAction = "http://www.webserviceX.NET/GetCitiesByCountry";
    
    request.addProperty("CountryName", "india");
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.bodyOut = request;
    envelope.dotNet = true;
    
    HttpTransport ht = new HttpTransport("http://www.webservicex.net/globalweather.asmx");
    ht.debug = true;
    //System.err.println( ht.requestDump );
    
    ht.call(soapAction,envelope);
    System.out.println("####################: " +envelope.getResponse());
    //SoapObject result = (SoapObject)envelope.getResponse();
    

    So basically you should just take your soapObject and call addProperty() to it.

提交回复
热议问题