2016-04-08 3 views
0

Wenn ich zu meinem WCF-Service mit Andoroid Volley-Bibliothek aufrufen, werfen TimeOut Exception. Das ist mein Code. Was ist der Fehler dieses Codes?Get WCF REST GET Anfrage in Android

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-Endpunkt

<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> 

Schnittstelle - IDisasterTypeService
Methode aufrufen müssen - GetAllDisasterType

+0

scheint es, dass es ausläuft. Was sind die Serverlogs – djodjo

+0

Kann ich diesen Service Usign KSOAP2-Bibliothek aufrufen? –

+0

seit du JSON zurückbringst, sehe ich keinen Grund, warum die Verwendung von ksoap2 + soap alt und weniger unterstützt wird. Dies ist jedoch nicht Ihr Problem. Wenn Sie eine Zeitüberschreitung haben, müssen Sie auf dem Server überprüfen, warum es passiert. – djodjo

Antwort

0

ich die Lösung gefunden. Ich habe eine Bindung zur Datei applicationhost.config auf dem IIS-Server hinzugefügt.

<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> 

Dann installierte ich iis Proxy und ändern den Port Proxy

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

10963 ist der Hafen, die Anwendung und die 8085 ist der Proxy-Port

Finale I geändert Meine URL in Android-Anwendung

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

more information