在Android中调用WebService

时间:2012-11-06 08:58:10

标签: android

主要执行SQL。我下载了断点。也许在句子if (envelope.getResponse() != null)中它获得了null对象,所以它在返回null值后完成。我在SQL中监视,发现它没有执行SQL语句。例如:ht.call("http://toeye.net/" + MothodName, envelope);它也没有在webservice中执行。

public static String sSQL(String SQL)
{
    String MothodName = "ExecSQL";
    HttpTransportSE ht = new HttpTransportSE("http://192.168.1.80/YFService.asmx?WSDL");
    ht.debug = true;
    // use SOAP1.1 creat Envelop object
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
        SoapEnvelope.VER12);
    // instantiate SoapObject
    SoapObject soapObject = new SoapObject("http://toeye.net/", MothodName);
    soapObject.addProperty("SQLString", SQL);
    envelope.bodyOut = soapObject;
    // set the Web Service which applied by .Net and keep the compatibility
    envelope.dotNet = true;
    try
    {
        // call Web Service
        ht.call("http://toeye.net/" + MothodName, envelope);
        if (envelope.getResponse() != null)
        {
            // Access server response and return SOAP message
            SoapObject result = (SoapObject) envelope.bodyIn;
            SoapObject detail = (SoapObject) result.getProperty(MothodName
                + "Result");
            // Analytic server response SOAP message
            return detail.toString();
        }
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    catch (XmlPullParserException e)
    {
        e.printStackTrace();
    }
    return null;
}

0 个答案:

没有答案