【问题标题】:Android KSoap errorAndroid KSoap 错误
【发布时间】:2016-12-29 12:33:20
【问题描述】:

我正在使用soap访问如下所示代码中的Web服务并得到以下错误,我需要帮助理解:

SoapFault - 故障代码:'soap:Server' faultstring:'System.Web.Services.Protocols.SoapException:服务器无法 处理请求。 ---> System.Data.SqlClient.SqlException:过程或 函数“getWCity”需要参数“@CountryName”,而这不是 提供。 在 WebServicex.GlobalWeather.GetCitiesByCountry(字符串 CountryName) --- 内部异常堆栈跟踪结束 ---' 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;
}

【问题讨论】:

  • 语法改进

标签: java android web-services ksoap


【解决方案1】:

SoapObject(NAMESPACE, METHOD_NAME);它用作命名空间:

http://www.webserviceX.NET/

但应该是的

http://www.webserviceX.NET

你可以改成:

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


SOAP_ACTION = NAMESPACE + "/" + METHOD_NAME;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多