服务调用的SoapObject结果总是空 [英] SoapObject result of service call is always null

查看:887
本文介绍了服务调用的SoapObject结果总是空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了我的谷歌开发者网站上找到教程以下SOAP Web服务,现在我正在写使用kso​​ap2库,(在一个TextView现在)调用可用的服务,并显示结果的Andr​​oid应用程序。
这就是code:

I have implemented my SOAP webservice following the tutorial found on google developers website, and now i'm writing a android app that call an available service and show result (for now in a textview) using ksoap2 libraries. That's the code:

public class DownloadDataTask extends AsyncTask<Void, Void, SoapObject> {
private static String METHOD_NAME = "getData";
private static String SOAP_ACTION = "http://example.com/getData";
private static String WSDL_URL = "http://arduino-data-server.appspot.com/FunctionsService.wsdl";
private static String NAMESPACE = "http://example.com/";
private MainActivity caller_activity;

public DownloadDataTask(MainActivity a) {
    caller_activity = a;
}

@Override
protected SoapObject doInBackground(Void... arg0) {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER12);
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(WSDL_URL);

    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.getResponse();
        return result;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;
}

@Override
protected void onPostExecute(SoapObject result) {
    TextView tw = (TextView) caller_activity.findViewById(R.id.text_view);
    if (result == null) {
        tw.setText("NULL");
    } else {
        tw.setText(result.getName());
    }
}
}

但每次,结果SoapObject它为空。怎么了? AppEngine上服务器日志,我可以看到,Android应用要求WSDL文件,但没有服务发送请求。什么是错的(WSDL文件是我的code内可用的广告网址写)?

but everytime, the result SoapObject it's null. what's wrong? on appengine server log, i can see that android app ask for wsdl file, but no request for service was sent. What's wrong (wsdl file is available ad url write inside my code)?

推荐答案

KSOAP不使用WSDL(因此不要求的话)。你应该通过服务URL,而不是WSDL URL。服务URL可以在WSDL中找到(属性位置在服务描述部分的地址元素)。

Ksoap doesn't use wsdl (and so doesn't request it). You should pass service url instead of wsdl url. Service url you can find in wsdl (attribute location of the address element in the service description section).

这篇关于服务调用的SoapObject结果总是空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆