2016-04-08 8 views
0

andoroid volley libraryを使用してWCFサービスを呼び出すと、TimeOut Exceptionがスローされます。これは私のコードです。このコードのエラーは何ですか?AndroidでWCF REST GETリクエストを取得する

RequestQueue queue = Volley.newRequestQueue(getApplicationContext()); 
String URL = "http://192.168.42.200:10963/DisasterService.svc/type/findDisType"; 
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, URL, null, 
     new Response.Listener<JSONObject>() { 
      @Override 
      public void onResponse(JSONObject response) { 
       try { 

        Toast.makeText(getApplicationContext(),"Ok",Toast.LENGTH_SHORT).show(); 
        Toast.makeText(getApplicationContext(),response.toString(),Toast.LENGTH_SHORT).show(); 
       } catch (Exception e) { 
        Toast.makeText(getApplicationContext(),e.toString(),Toast.LENGTH_SHORT).show(); 
       } 
      } 
     }, 
     new Response.ErrorListener() { 
      @Override 
      public void onErrorResponse(VolleyError error) { 
       Toast.makeText(getApplicationContext(),error.toString(),Toast.LENGTH_SHORT).show(); 
      } 
     }); 
jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(30000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); 
queue.add(jsonObjectRequest); 

WCFサービスのエンドポイント

<service name="DisasterServices.DisasterService" behaviorConfiguration="DisasterServices_Behavior"> 

     <endpoint address="area" binding="webHttpBinding" contract="DisasterServices.IAreaService"></endpoint> 
     <endpoint address="type" binding="webHttpBinding" contract="DisasterServices.IDisasterTypeService"></endpoint> 
     <endpoint address="suggestion" binding="webHttpBinding" contract="DisasterServices.ISuggestion"></endpoint> 
     <endpoint address="user" binding="webHttpBinding" contract="DisasterServices.Iuser"></endpoint> 
     <endpoint address="alerts" binding="webHttpBinding" contract="DisasterServices.IUserAlerts"></endpoint> 

     </service> 

インタフェース - IDisasterTypeService
メソッドを呼び出す必要がある - GetAllDisasterType

+0

これはタイムアウトしたようです。 – djodjo

+0

このサービスをKSOAP2ライブラリを使用して呼び出すことはできますか? –

+0

あなたはjsonを返すので、なぜksoap2 + soapを使用するのが古くてサポートが少ないのかわかりません。しかし、これは問題ではありません。タイムアウトが発生した場合、サーバーがなぜ起きているかを確認する必要があります。 – djodjo

答えて

0

私はこのための解決策を見つけました。私は、IISサーバーのapplicationhost.configファイルにいくつかのバインディングを追加しました。

<site name="myservice" id="5"> 
      <application path="/" applicationPool="Clr4IntegratedAppPool"> 
       <virtualDirectory path="/" physicalPath="E:\vs\myservice" /> 
      </application> 
      <bindings> 
       <binding protocol="http" bindingInformation="*:10963:127.0.0.1" /> 
       <binding protocol="http" bindingInformation="*:8085:127.0.0.1" /> 
       <binding protocol="http" bindingInformation="*:8085:192.168.42.200" /> 
      </bindings> 

それから私は、IISプロキシをインストールし、プロキシ

npm install -g iisexpress-proxy 
iisexpress-proxy 10963 to 8085 

10963にポートを変更するアプリケーションの実行および8085は、私が変更されたプロキシポート

決勝でポートですアンドロイドアプリケーションの私のURL

String URL = "http://192.168.42.200:8085/myservice.svc/test/2"; 

more information

関連する問題