简体   繁体   中英

Android KSoap error

I'm using soap to access a web service in the code shown below and get the following error, which I need help in understanding:

SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'getWCity' expects parameter '@CountryName', which was not supplied. at WebServicex.GlobalWeather.GetCitiesByCountry(String CountryName) --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@bf51d7c

public String Test()
{
    String SOAP_ACTION = "http://www.webserviceX.NET/GetCitiesByCountry";
    String METHOD_NAME = "GetCitiesByCountry";
    String NAMESPACE = "http://www.webserviceX.NET/";
    String URL = "http://www.webservicex.com/globalweather.asmx?WSDL";

    SOAP_ACTION = NAMESPACE + METHOD_NAME;
    String result="invalid";
    try
    {
        SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
        Request.addProperty("CountryName", "India");

        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet = true;
        soapEnvelope.setOutputSoapObject(Request);
        HttpTransportSE transport = new HttpTransportSE(URL);
        transport.call(SOAP_ACTION, soapEnvelope);
        SoapPrimitive resultString;
        resultString = (SoapPrimitive) soapEnvelope.getResponse();
        result = resultString .toString() ;
        return result ;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return  result;
}

The SoapObject(NAMESPACE, METHOD_NAME); it uses as the namespace:

" http://www.webserviceX.NET/ "

but it should be

" http://www.webserviceX.NET "

you could change to:

String METHOD_NAME = "GetCitiesByCountry";
String NAMESPACE = "http://www.webserviceX.NET";


SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM