title: I am almost there...PhoneGap Android connect to WCF Service
body: <p>Firstly I would like to thank all the experts here on stackoverflow, by reading questions asked and looking at example code and reading the answers i have been able to get to this point. Thank you once again!</p>
  
  <p>I have been spending hours and hours searching for a solution, I’ve read through many posts on this issue.  It’s seem this is a issue a lot of others are/has been struggling with.I would highly appreciate any more advise or tips if somebody can assist in this frustrating issue.</p>
  
  <p>All my development are done on my local machine. (Win 7, Visual Studio 11beta)</p>
  
  <p>A WCF Service is hosted in IIS Express on its own port or IIS 7.5 (.Net Framework 4.0)</p>
  
  <p>Second Web Application with only Html5/jQuery is hosted in IIS Express on a different port.</p>
  
  <p>Using Eclipse 3.7.2 with Android SDK 17 also on my local machine.
  Its seem all the software are functioning properly.
  Android Emulator is working,  Phonegap/Cordova library is installed, etc.
  I am using Android 4.0.3 with Cordova 1.6.0</p>
  
  <p>I am asking assistance to find out why my phonegap emulator ajax call won’t go through to my WCF REST Service. I don’t have a actual android device now  to test the program on at this moment therefore I must use the Emulator.</p>
  
  <p>Some more detail:</p>
  
  <p>I have a WCF REST Service developed in .Net receiving &amp; sending in JSON and JSON-P.</p>
  
  <p>I have tested this with a second web application on a different port to make sure cross domain calls are allowed.</p>
  
  <p>I have also used the RESTclient plugin for Firefox and can use it to make JSON and JSON-P calls successfully. [ <a href="http://restclient.net/" rel="nofollow">http://restclient.net/</a> ]
  So I am sure the WCF Service is working as it should. There shouldn't be any cross domain issue.</p>
  
  <p>When I take the Html file with jQuery that I know is working within Visual Studio, to eclipse, copy into phonegap app, I  try to make a basic call to my WCF server and I am unable to connect to the server.</p>
  
  <p>I have changed the URL from [http://localhost:50425/LoginService.svc/GetData] to  [http://10.0.2.2:50425/LoginService.svc/GetData] 
  according to android documentation : [http://developer.android.com/guide/developing/devices/emulator.html#networkaddresses] </p>
  
  <p>I have created an allow all whitelist with the following setting:</p>
  
  <p>[ access origin="*" ] </p>
  
  <p>within the cordova.xml file. See: [http://professionalaspnet.com/archive/2012/05/15/Whitelisting-Domains-in-Cordova-_2800_PhoneGap_2900_-Android.aspx]</p>
  
  <p>The correct permissions have been set inside the AndroidManifest.xml file according to  [http://docs.phonegap.com/en/1.8.1/guide_getting-started_android_index.md.html#Getting%20Started%20with%20Android]</p>
  
  <p>When I initiate the call, I use  $.ajaxSetup error function to trap network error etc. and display with alert the error message.  Used console.log() to make sure it passes this function without a error.</p>
  
  <p>When the call actually happens, I receive a "Bad Request - Invalid Host Name. HTTP 400. The request hostname is invalid."</p>
  
  <p>If the call would have been successful, I use breakpoints inside Visual Studio to know for certain the call has been made and see the request coming through.</p>
  
  <p>Is there any other ways to test from emulator if I can access the "external" host? In this case to make sure emulator actually can find the service? 
  Is there any tools or other configuration settings that needs to be done?</p>
  
  <p>I have even deleted my emulator and created a new one but it still fails to connect to the WCF Service.</p>
  
  <p>I would really like this to work, would like to build a complete phonegap application but can’t continue if I can't make a call to a web service.</p>
  
  <p>Any advise would be greatly appreciated.</p>