Search code examples
androidksoap2

xmlpullparserexception expected: START_TAG


I have the following:

public String searchRecipes( String searchString, int pageNumber ) throws Exception
    {
        SoapObject _client = new SoapObject( "", "searchRecipes" );
        _client.addProperty("searchString", searchString);
        _client.addProperty("pageNumber",   pageNumber);

        SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11 );
        _envelope.bodyOut = _client;

        Marshal dateMarshal = new MarshalDate();
        dateMarshal.register(_envelope);

        HttpTransportSE _ht = new HttpTransportSE(Configuration.getWsUrl());
        _ht.call("", _envelope);

        return  _envelope.getResponse().toString();
    }

It works fine when I use it on my local server on the PC using the eclipse. But when I deploy it I get:

expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:6 in java.io.InputStreamReader@4056fb48) 

Can anybody help? I am facing it for more than a week.........


Solution

  • Well, I think NAMESPACE string should be the first argument in SoapObject constructor. The same for the call() method (here should be NAMESPACE + METHOD_NAME as the first parameter)

    And try this:

    _envelope.setOutputSoapObject(_client);
    

    instead of this:

    _envelope.bodyOut = _client;
    

    To get the response: it depends on what your web service is returning (a primitive or complex object?)