0

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();
  }
ankit rawat
  • 401
  • 2
  • 9
  • 22

1 Answers1

1

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>
OldProgrammer
  • 12,050
  • 4
  • 24
  • 45
  • Yes, there is library support in android. I have completed everything in the code, just need to know the return type format for a function named getCountryList(). I need to know that so that I can suitably accept and process the data. Is there any way to figure out the return type? – ankit rawat Feb 02 '13 at 20:08
  • It is in the WSDL, no? Please post the WSDL file. – OldProgrammer Feb 02 '13 at 21:10
  • http://api.radioreference.com/soap2/index.php?wsdl The name of the function needed is getCountryList – ankit rawat Feb 02 '13 at 21:20
  • Thanks, that helped. Can you also tell me how to put the names of the countries in an array? That would be a great help! Here is the code snippet where I do all this(in my question as an edit) – ankit rawat Feb 02 '13 at 22:06
  • Sorry, not familiar w/android environment. – OldProgrammer Feb 02 '13 at 22:49