首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SoapFault - faultcode:'soap:Server‘faultstring:’服务器无法处理未设置为对象实例的request.Object引用

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

Stack Overflow用户
提问于 2014-12-13 23:34:19
回答 1查看 2.4K关注 0票数 1

我有一个用asp.net编写的have服务。我想从安卓应用程序使用SOAP(ksoap2)访问webservice。

这是我的soap片段,

代码语言:javascript
复制
//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;
}

当我调试代码时,我有一个问题标题中提到的错误。错误显示在

代码语言:javascript
复制
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();

线路..。

我想我得不到webservice的响应。我怎么才能修复它?

Webservice返回xml.InnerText。它是字符串类型。

请回答我。

EN

回答 1

Stack Overflow用户

发布于 2014-12-14 00:11:38

虽然我不是.NET开发人员,但我在使用Java之前见过类似的错误代码,它总是归结为调用web service返回的XML无效。

在我的例子中,我尝试捕获原始XML响应,然后尝试使用XML解析库解析它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27460513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档