使用Ksoap调用SOAP Web服务

时间:2015-06-01 17:19:57

标签: android soap soapui android-webservice

我试图在SOAPUI中调用这样的肥皂。它有4个参数。网址是 - http://seycel.com.mx/ws/res2.php

输入就像这样 -

    `<usuario xsi:type="xsd:string">1212121212</usuario>
     <sms xsi:type="xsd:string">saldo</sms>
     <palabra xsi:type="xsd:string">0439267236</palabra>
     <fecha xsi:type="xsd:string">2015-05-20 20:10:10</fecha>`

enter image description here 我想从android调用它并获取返回标记。我想做的就是这样 -

private static final String SOAP_ACTION = "urn:recargas#saldo";
private static final String METHOD_NAME = "saldo";
private static final String NAMESPACE = "urn:recargas";
private static final String URL = "http://seycel.com.mx/ws/res2.php?wsdl";


    private class UserRegistrationTask extends AsyncTask<String, String, String>    {
    protected String doInBackground(String... values) {

        SoapPrimitive result = null;
        try {
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            request.addProperty("palabra", "0439267236");// Parameter for Method
            request.addProperty("usuario", "1212121212");// Parameter for Method
            request.addProperty("sms", "saldo");// Parameter for Method
            request.addProperty("fecha", "15-05-30 20:52:20");// Parameter for Method

            SoapSerializationEnvelope envelope =
                    new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);

            AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
            androidHttpTransport.call(SOAP_ACTION, envelope);

            result = (SoapPrimitive) envelope.getResponse();

        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }
        return result.toString();
    }

    protected void onPostExecute(String result) {
        Log.d("TAG", "value: " + result);
    }
}

得到类似java.lang.String的错误无法强制转换为org.ksoap2.serialization.SoapPrimitive

0 个答案:

没有答案