UnknownHostException:host is unresolved
well i know there are many questions of similar intent but i did not find any answer which proved to resolve this error Problem: i want to access .net webservice from my android application and i am getting this error. UnknownHostException:Host is Unresolved:webadress.com:80 earlier i tries this on emulator but got the same error n now even on device as well.... Guys plz help me out
ma code is:
public class FirstAppUI extends Activity {
private static final String NAMESPACE = "http://tempuri.org/";
pr开发者_C百科ivate static final String URL =
//"http://192.168.41.201:52002/WebServiceAvail/Service.asmx";
"http://nautilussoft.biz.whbus12.onlyfordemo.com/staging/litigation/litwebservice.asmx";
private static final String SOAP_ACTION = "http://tempuri.org/";
private static final String METHOD_NAME = "GetUserByUserName(a,10)";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv= (TextView)findViewById(R.id.TextView01);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope =
new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//Toast.makeText(getBaseContext(), "received object", Toast.LENGTH_SHORT).show();
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
//Toast.makeText(getBaseContext(), "received object", Toast.LENGTH_SHORT).show();
tv.setText("Received :" + resultsRequestSOAP.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
Log.e("APP", "MalformedURLException while sending\n" + e.getMessage());
tv.setText("Malformedexception"+e);
}
catch(Exception e1)
{tv.setText("exception"+e1);}
}
}
The host , or the server where information is residing is not reachable , so you are getting this error. This can be because of various reasons , like you are not connected to Internet and connection is lost while trying to connect to the server and url might be wrong.
If you are getting reply message from your webservice in browser , then there is a problem in app , otherwise problem in network connection.
Use "http://www.tempuri.org/"; inplace of "http://tempuri.org/";
"like you are not connected to Internet and connection is lost while trying to connect to the server and url might be wrong."
Please check your Internet Connection in emulator
精彩评论