1

我尝试通过 ksoap2 连接 Android - webservice。我有个问题。当我在 Java 中运行控制台应用程序时,它运行正常。但是当我将此代码复制到 Android 时,它会出现错误:

“Java.Net.UnknowHostException.jeryservice.somee.com”。

我的代码:

String NAMESPACE = "http://jeryservice.somee.com/";
String URL = "http://jeryservice.somee.com/myservice/Service1.asmx";
String SOAP_ACTION = "http://jeryservice.somee.com/test";
SoapObject request= null;
String rs="";
request=new SoapObject(NAMESPACE,"test");
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
request.addProperty("name", " Jery ok man");
envelope.setOutputSoapObject(request);
HttpTransportSE transp=null;
transp=new HttpTransportSE(URL);
try {
  transp.call(SOAP_ACTION, envelope);
  Object rsl=envelope.getResponse();
  rs=rsl.toString();
  Toast.makeText(getApplicationContext(),"ok-> "+ rs, Toast.LENGTH_SHORT).show();
  catch(Exception ex) {
    Toast.makeText(getApplicationContext(), "error->"+ ex.toString(), Toast.LENGTH_SHORT).show();
    ex.printStackTrace();
  }
}
4

1 回答 1

1
<uses-permission android:name="android.permission.INTERNET" />
于 2012-08-31T10:27:03.017 回答