Java Android IO异常-没有此类文件或目录
我正在将我的Android应用程序与webservice.asmx连接。。。 我得到一个类似IOException的错误,没有这样的文件或目录。我在下面给出我的代码。。我收到祝酒词“请稍后再试”,所以发生了一般性异常Java Android IO异常-没有此类文件或目录,java,android,exception,ioexception,Java,Android,Exception,Ioexception,我正在将我的Android应用程序与webservice.asmx连接。。。 我得到一个类似IOException的错误,没有这样的文件或目录。我在下面给出我的代码。。我收到祝酒词“请稍后再试”,所以发生了一般性异常 webserviceCallButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // T
webserviceCallButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new login().execute();
}
});
}
class login extends AsyncTask<Void, Void, Void> {
private final ProgressDialog dialog = new ProgressDialog(Sample1_Page.this);
@Override
protected void onPreExecute() {
this.dialog.setMessage("Loading data");
this.dialog.show();
}
@Override
protected Void doInBackground(Void... unused) {
final String NAMESPACE = "https://xxx.xxxx.com/";
final String URL = "https://xxx.xxxx.xxx.com/appservice/d_service.asmx";
final String SOAP_ACTION = "https://xxxx.xxx.com/mLo";
final String METHOD_NAME = "mLo";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("userid", userid);
request.addProperty("password", password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
String responseJSON=response.toString();
JSONArray jarray =new JSONArray(responseJSON);
Name=jarray.getJSONObject(0).getString(TAG_NAME);
Id=jarray.getJSONObject(0).getString(TAG_ID);
System.out.println(request);
System.out.println(responseJSON);
}
catch(SocketTimeoutException e){
timeoutexcep=true;
e.printStackTrace();
}
catch(UnknownHostException e){
httpexcep=true;
e.printStackTrace();
}
catch (Exception e) {
genexcep=true;
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (this.dialog.isShowing()) {
this.dialog.dismiss();
}
if(timeoutexcep){
Toast.makeText(Sample1_Page.this, "Unable to connect to server, Please try again later",Toast.LENGTH_LONG).show();
}
else if(httpexcep){
Toast.makeText(Sample1_Page.this, "Please check your Internet connection",Toast.LENGTH_LONG).show();
}
else if(genexcep){
Toast.makeText(Sample1_Page.this, "Please try later",Toast.LENGTH_LONG).show();
}
else{
tableview();
}
timeoutexcep=false;
httpexcep=false;
genexcep=false;
}
public void tableview(){
try{
TextView webserviceResponse = (TextView) findViewById(R.id.textView1);
webserviceResponse.setText(Name);
}
catch(Exception e){
}
}
}
你能给我看一下你的清单权限吗 你必须有这个权限。如果没有,则添加此项
android.permission.WRITE_EXTERNAL_STORAGE
还要检查web服务的协议,是https还是http?尝试使用服务器的ip地址。它可能会对您有所帮助。将您的url更改为
https://xxx.xxxx.xxx.com/appservice/d_service.asmx/
然后再试一次,可能会有帮助。您可以只使用url中的控制器名称再试一次吗,省略扩展部分。我是用servlet做的。@csuman。。。哪一个是控制器名称?“您可以在评论中说明这一点,我不明白为什么您要求写入storageweb服务协议的权限是httpsI没有授予外部存储权限这是一个IO例外,因此会有与环境相关的IO权限或根访问权限来执行此类命令,也许超级用户权限有帮助。@Pankaj。。。超级用户权限,,,Means
android.permission.WRITE_EXTERNAL_STORAGE