IISを使用してlocalhostでRestful WCFサービスを公開しました。 http://localhost/mobservice/MobSrv.svcandroid studioがlocalhost WCFサービスに接続できません
getCityListは、このサービスのwebGetメソッドで、都市リストを返します。私はのAndroid Studioでこのサービスを利用しています。
java.io.FileNotFoundException:http://10.0.2.2/mobservice/MobSrv.svc/getCityList
私のAndroidのコードは次のようである:
String serviceUrl="http://10.0.2.2/mobservice/MobSrv.svc/getCityList";
URL urlToRequest = new URL(serviceUrl);
urlConnection = (HttpURLConnection)
urlToRequest.openConnection();
int statusCode = urlConnection.getResponseCode();
if (statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
// handle unauthorized (if service requires user login)
} else if (statusCode != HttpURLConnection.HTTP_OK) {
// handle any other errors, like 404, 500,..
}
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
からstatusCodeは値404、およびのURLConnectionを返します。しかし、私のアンドロイドのプログラムでは、エラーを示しています.getInputStream()例外を与えるjava.io.FileNotFoundException上記のとおりです。
アンドロイドスタジオでADBインテグレーションが有効になっています。
それは例外を示している番組のラインです。取得している例外階層メッセージを提供してください。 – SachinSarawgi
私は詳細を編集しました。 – Admin
@SachinSarawgi私はgoogledとローカルホスト10.0.2.2を使用してアクセスすることを知ってきたが、それは動作していない – Admin