照网上的例子抄的,主要是执行一段SQL语句,
下断点试了,
在这一条语句中
if (envelope.getResponse() != 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;
// 使用SOAP1.1协议创建Envelop对象
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
// 实例化SoapObject对象
SoapObject soapObject = new SoapObject("http://toeye.net/", MothodName);
soapObject.addProperty("SQLString", SQL);
envelope.bodyOut = soapObject;
// 设置与.Net提供的Web Service保持较好的兼容性
envelope.dotNet = true;
try
{
// 调用Web Service
ht.call("http://toeye.net/" + MothodName, envelope);
if (envelope.getResponse() != null)
{
// 获取服务器响应返回的SOAP消息
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) result.getProperty(MothodName
+ "Result");
// 解析服务器响应的SOAP消息。
return detail.toString();
}
}
catch (IOException e)
{
e.printStackTrace();
}
catch (XmlPullParserException e)
{
e.printStackTrace();
}
return null;
}

解决方案 »

  1.   

    不能用本地的url,得用服务器发布的url
      

  2.   

    LZ 问题解决没  我和你遇到一模一样的问题   返回为NULL
      

  3.   

    参数只有一个,SQL语句,肯定是对的,也能通过测试
      

  4.   

     ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
     nameValuePairs.add(new BasicNameValuePair("Your_var_1", value));
     nameValuePairs.add(new BasicNameValuePair("Your_var_2", value));
    然后再创建你的web链接
     try
        {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("your url only ex:www.google.com/abc");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpParams httpParameters = new BasicHttpParams();
            DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        } catch (Exception e) 
        {   
            Log.e("Loading Runnable Error in http connection  :", e.toString());
        }
    现在检索响应流
    try 
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) 
            {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
        }
        catch (Exception e) 
        {   
            Log.e("Loading Runnable Error converting result :", e.toString());
        }
    现在在最终的结果中包含整个输出字符串,就取决于你如何读取数据。我使用json示例代码,希望能帮得上你啊。
    JSONObject json_data = new JSONObject(result);// its a string var which contain output. 
            my_output_one = json_data.getString("var_1"); // its your response var form web.
            my_output_two = json_data.getString("var_2");
      

  5.   

    1.192.168.1.80不行,你如果是asp.net做的项目的话,将该项目挂在IIS上再用android访问。
    2.如果要调试,在vs中->调试->附加到进程,将挂在IIS上的那个进程选中,然后你android访问的时候它会进入到你打断点的地方。
      

  6.   

    已解决,更换KSOAP包为2.6.5后
    不清楚原因,望哪位大侠告知