主机未解析...未知主机异常

时间:2011-09-13 06:22:06

标签: android soap-serialization

public class main extends Activity {

    /** Called when the activity is first created. */
    private static String SOAP_ACTION = "http://footballpool.dataaccess.eu/data/TopGoalScorers";
    private static String NAMESPACE = "http://footballpool.dataaccess.eu";
    private static String METHOD_NAME = "TopGoalScorers";
    private static String URL = "http://footballpool.dataaccess.eu/data/info.wso?WSDL";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("iTopN", 5);

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

    // Make the soap call.
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    //AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport("http://www.google.co.in");

     try {
        // this is the actual part that will call the webservice
        androidHttpTransport. call(SOAP_ACTION, envelope);
     } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
     }
    // Get the SoapResult from the envelope body.
    SoapObject result = (SoapObject) envelope.bodyIn;
  }
}

1 个答案:

答案 0 :(得分:3)

您是否在清单文件中添加了INTERNET权限?