android 天气预报 wifi无法取到数据 模拟器可以.求助呀...代码如下
private static final String SERVICE_URL = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";
private static final String SERVICE_WEB = "http://WebXml.com.cn/"; /**
 * 获取天气
 */
public static SoapObject getWeather(String city)
{
Log.i("info", "getWeather city" + city); String name = "getWeather";
SoapObject request = new SoapObject(SERVICE_WEB, name);
request.addProperty("theCityCode", city); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapSerializationEnvelope.VER12);
envelope.bodyOut = request;
envelope.dotNet = true; HttpTransportSE ht = new HttpTransportSE(SERVICE_URL);
try
{
ht.call(SERVICE_WEB + name, envelope);
if (envelope != null)
{
SoapObject response = (SoapObject) envelope.bodyIn;
SoapObject detail = (SoapObject) response.getProperty(name
+ "Result"); return detail;
}
} catch (IOException e)
{
e.printStackTrace();
} catch (XmlPullParserException e)
{
e.printStackTrace();
} return null;
}