Search code examples
androidwsdl

What format does WSDL return in?


I am making an android app, and need to access an online WSDL based database. My code accesses a list of countries from that database, but I don't know what format I'll get the data in. eg. a single string, an array? etc.. So is there any standard return type for WSDL? Thanks.

edit: code snippet

        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION, envelope);

        // Get the SoapResult from the envelope body.
        SoapObject result = (SoapObject)envelope.bodyIn;

    if(result!=null)
    {
        //put the value in an array
        // prepare the list of all records
         List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
        for(int i = 0; i < 10; i++){
            HashMap<String, String> map = new HashMap<String, String>();
            map.put(result.getProperty(i).toString());
            fillMaps.add(map);
            lv.setOnItemClickListener(onListClick);
        }
     // fill in the grid_item layout
        SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.grid_item, from, to);
        lv.setAdapter(adapter);
    }
        else
        {
              Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
        }
  } catch (Exception e) {
        e.printStackTrace();
  }

Solution

  • WSDL is not a data format per-se. It is an XML-based description of a web service contract. The input parameters and resulting output are defined using the WSDL. See here WSDL

    Data is defined using the XML Schema Definition (XSD). See here XSD

    I am not familiar w/Android, but there should be some library support or 3rd party tool to read the WSDL definition and create java classes that represent the client proxy.

    (updated) The response returns a type of "Countries"

    <message name="getCountryListResponse">
     <part name="return" type="tns:Countries"/>
    </message>
    

    If you look at the "Countries" type, it is an array of "Country" types:

    <xsd:complexType name="Countries">
    <xsd:complexContent> 
    <xsd:restriction base="SOAP-ENC:Array">
    <xsd:attribute wsdl:arrayType="tns:Country[]" ref="SOAP-ENC:arrayType"/>
     </xsd:restriction> 
    </xsd:complexContent> 
    

    The "Country" type has the three elements below.

    </xsd:complexType> -
    <xsd:complexType name="Country">
    <xsd:all> 
    <xsd:element name="coid" type="xsd:int"/>
    <xsd:element name="countryName" type="xsd:string"/> 
    <xsd:element name="countryCode" type="xsd:string"/>
    </xsd:all>
    </xsd:complexType>
    

    So, if your android code does not create a client proxy, you would need to parse the XML for the data as represented above.

    It probably looks like something (simplified):

    <Countries>
      <Country>
        <coid>123</coid>
        <countryName>France</countryName>
        <countryCode>111</countryCode>
    </Countries>