Question

I'm having trouble trying to receive structured data from ksoap getResponse();

I've already read carefully guide to send and receive data using SoapObjects from site: link to site

I'm using this WSDL

The object i'm trying to obtain has structure like:

<message name="doSearchResponse">
   <part name="search-count" type="xsd:int"/>
   <part name="search-count-featured" type="xsd:int"/>
   <part name="search-array" type="typens:ArrayOfSearchResponse"/>
   <part name="search-excluded-words" type="typens:ArrayOfExcludedWords"/>
   <part name="search-categories" type="typens:ArrayOfCategoriesStruct"/>
</message>

I think this is kind of output object that is used in doSearch method:

<operation name="doSearch">
    <input message="typens:doSearchRequest"/>
    <output message="typens:doSearchResponse"/>
</operation>

This is te code I'm trying to perform search operation and then to get the object I presented above (doSearchResponse).

public void search(String searchPhrase) {

    /* search criteria holder */
    SoapObject searchOptType = new SoapObject(API_NAMESPACE, "SearchOptType");
    searchOptType.addProperty("search-string", searchPhrase);

    /* search method */
    SoapObject doSearch = new SoapObject(API_NAMESPACE, "doSearch");
    doSearch.addProperty("session-handle", sessionToken);
    doSearch.addProperty("search-query", searchOptType);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);

    envelope.dotNet = true;

    envelope.setOutputSoapObject(doSearch);

    Object response = null;
    try {
        transport.call("", envelope);

        response = envelope.getResponse();
        System.out.println(response.getClass());
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

Search works fine, but it returns me only one Object - an single Integer object(not an array) which is the count of found matching items to the searchPhrase. And i think this is the first position in doSearchResponse object. But I need rest of them, especially: search-array. What am I doing wrong? Isn't this sth to deal with envelope.call("and this string here", ...)?

Était-ce utile?

La solution

you will replace "" into SOAP_ACTION that's like given below

 transport.call(SOAP_ACTION, envelope);

And Also Have you checked response type is string or array..

Autres conseils

I solved it.

The problem was the KSOAP2 library in version 2.4. Actually I don't know why it was returning only an single Integer object. But in version 3.0.0 RC4 doing it the same way it returns me Vector object fulfilled with objects I expected. So anyway thanks :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top