locked
Windows Phone and Web API testing RRS feed

  • Question

  • User-969659544 posted

    New to Windows Phone development.  I am working on a project where the end solution will run on our company intranet.  

    End Solution: Windows Phones using WiFi will make calls to a Web API hosted on IIS.  The Web API connects to data in SQL Server 2014 in the same domain as IIS.

    I have written the Web API in VS 2013 on my PC.  SQL 2014 Dev also installed on same PC.  CRUD tested with Fiddler and it works fine.

    Now I want to work on the Windows Phone project to call the Web API.  

    What is the best way to test?

    I have read this article and the contained link about testing on localhost: http://www.asp.net/web-api/overview/mobile-clients/calling-web-api-from-a-windows-phone-8-application.  On first look the extra steps to setup environment in localhost look complicated.

    I have read a little about publishing the Web API to Azure App Services for testing.

    Can I install IIS on my PC, host the Web API on it, bind it to some "friendly" address and use that address in the Windows Phone API calls?

    Too much info and I am trying to pick the best path forward with this project.

    Thx

    Sunday, May 1, 2016 5:27 PM

Answers

  • User-782232518 posted

    The steps were complicated because Windows Phone emulator has all those restrictions to break. If you can only use the emulator, you have to follow them.

    If you can use a real device, then simply make sure your Web API project is hosted on IIS or IIS Express and binds to an URL (such as http://192.168.1.1) that can be internally visible (not easy for IIS Express), and then you can connect to the Web API project on that phone (whose IP might be 192.168.1.2). 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 25, 2016 8:42 AM

All replies

  • User-782232518 posted

    The steps were complicated because Windows Phone emulator has all those restrictions to break. If you can only use the emulator, you have to follow them.

    If you can use a real device, then simply make sure your Web API project is hosted on IIS or IIS Express and binds to an URL (such as http://192.168.1.1) that can be internally visible (not easy for IIS Express), and then you can connect to the Web API project on that phone (whose IP might be 192.168.1.2). 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 25, 2016 8:42 AM
  • User-969659544 posted

    lextm - 

    Thanks for the info.  I stumbled upon this same approach.  

    You need to add a binding statement in the IIS Express appplicationhost file using your PC IP address and some port.  I just used the port assigned when testing with localhost.

    For example: <binding protocol="http" bindingInformation="*:54384:192.168.1.118" />

    I also added the port to the Inbound and Outbound rules of the Windows firewall

    The gotcha is you need to run VS "As Administrator", so IIS Express will start as Admin.  Not sure if it's the IP address or port range, but I just run VS as Admin all the time to avoid any problem.

    This makes the Web API visible in your network.

    Sunday, May 29, 2016 3:45 PM