SoapObject result of service call is always null

一世执手 提交于 2019-12-14 03:07:12

问题


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());
    }
}
}

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)?


回答1:


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).



来源:https://stackoverflow.com/questions/18600411/soapobject-result-of-service-call-is-always-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!