SoapFault - faultcode:' soap:Server' faultstring:'服务器无法处理request.Object引用未设置为对象的实例

时间:2014-12-13 15:34:19

标签: java android asp.net web-services soap

我在asp.net中编写了一个web服务。我想使用SOAP(ksoap2)从android应用程序到达webservice。

这是我的肥皂片段,

//Namespace of the Webservice - can be found in WSDL
private static String NAMESPACE = "http://tempuri.org/";
//Webservice URL - WSDL File location
private static String URL = "http://locationbasedapp.net/Service1.asmx";//Make sure you changed IP address
//SOAP Action URI again Namespace + Web method name
private static String SOAP_ACTION = "http://tempuri.org/";

public static String invokeListLocationsWS(String datetext, String webMethName) {
    String xmlDataSet = "";
    // Create request
    SoapObject request = new SoapObject(NAMESPACE, webMethName);
    // Property which holds input parameters
    PropertyInfo datetextPI = new PropertyInfo();
    PropertyInfo passPI = new PropertyInfo();
    // Set Username
    datetextPI.setName("datetext");
    // Set Value
    datetextPI.setValue(datetext);
    // Set dataType
    datetextPI.setType(String.class);
    // Add the property to request object
    request.addProperty(datetextPI);

    // Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    // Set output SOAP object
    envelope.setOutputSoapObject(request);
    // Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        // Invoke web service
        androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
        // Get the response
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        // Assign it to  boolean variable variable

        xmlDataSet =response.toString();

    } catch (Exception e) {
        //Assign Error Status true in static variable 'errored'
        MapActivity.errored = true;
        e.printStackTrace();
    }
    //Return booleam to calling object
    return xmlDataSet;
}

在我调试代码时,我遇到了问题标题中提到的错误。

上可以看到错误
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();

线..

我想我无法从webservice获得回复。我该如何解决?

Webservice返回xml.InnerText。它是String类型。

请回答我。

1 个答案:

答案 0 :(得分:0)

虽然我不是.NET开发人员,但我在使用Java之前看到了类似的错误代码,并且它总是归结为调用XML无效的web service

在我的情况下,我尝试的是捕获原始XML响应,然后尝试使用XML解析库解析它。