Connecting local web service (WCF) from Windows Phone 8 Emulator

Connecting local web service (WCF) from Windows Phone 8 Emulator

So I’m right you came to this blog to resolve web services issue in windows phone 8 emulator. Let us discusses about it. Previously in windows phone 7 in OS 7.1 local web service was connected and consumed using http://localhost:port . But in windows phone 8 things are changed. Windows phone 8 emulator works as a separate device like another PC. We are well aware of the fact that localhost does not work on two different machines. That is the basic reason why windows phone 8 emulator generates exception.

Now, real part of my blog starts here,


1) Create a firewall exception to allow World Wide Web Services (HTTP) through the firewall.
2) From the Windows Start screen, search for Turn Windows features on or off. Click to run the program.
3) In the Windows Features dialog box, expand .NET Framework 4.5 Advanced Services, then expand WCF Services.
4) Under WCF Services, check the box next to HTTP Activation. Click OK to install this feature.

How can we remove this exception and how can we consume local web services?
  Move to start screen and search for Windows Firewall. Click to run it.
 When you have opened Windows Firewall screen, click Advance settings.
 On the Windows Firewall with Advanced Security screen, select Inbound Rules. Then click New Rule.
 When you move to Rule Type page of the New Inbound Rule Wizard, select Port. Then click Next.
 When you navigate to Protocols and Ports page, enter the port number that IIS Express is using in the Specific local ports field. Then click Next.
You can find the port number on the Web page of project properties in Visual Studio.
 On the Action page, select Allow the connection. Then click Next.
 On the Profile page, select Private and, if applicable, Domain. Do not select Public. Then click Next.
 On the Name page, type a name for the rule – for example, Local web service for testing. Then click Finish.

Note: It is better to allow inbound rules for private and domain.



Everything goes fine here but the problem in windows phone 8 is this that consuming WCF is not that much charm in WP8


you do all steps but still you fail, here is the solution to the problem


When ever you use your ip address you consume WCF first register it .

CMD provides native command that can be used for registering the URL for cashing.

1) Run CMD as administrator and type this command

&#61656;2) Netsh http add urlacl url = http://<your ip> : <port>/ user = everyone

&#61656;3)  This will result in “Reservation successfully added”


if you want to read more on Netsh command, HERE you go!

       The next step is to deal with bindings on “applicationhost.config”
&#61656; Open “applicationhost.config” file in Notepad after searching it from start.
&#61656; In the configuration file, find the site element for the web service, WebServiceForTesting. The XML elements in the configuration file have the following hierarchy:

< configuration>
    <application Host>
            <site> … </site>
    </application Host>
< /configuration>
&#61656; Change binding here  as follow
< bindings>
       <binding protocol="http"           bindingInformation="*:60661:localhost" />
< binding protocol="http" bindingInformation="*:60661:<ip address>" />

Note : Use respective port number instead of 60661.
&#61656; Just replace the bindings with this code.
&#61656; After done! Save the file.
&#61656; Now run the web services from the web services WCF project.  It will run on localhost but in IIS
Express you’ll see two bindings of web services.

&#61656; If you will run http://<yourip>: 52335<your port>/ in a web explorer it will run as follow.

&#61656;  Now the next step is to add the service to windows phone application.
&#61656; Search it by http://<ip address>/Service1.svc
&#61656; You’ll discover the web service and now your are ready to go.

&#61656; Add a button to the XAML of your windows phone app and add following code in its handler.
private void Button_Click_1(object sender, RoutedEventArgs e)
            int testValue = 7;
ServiceReference1.Service1Client clientForTesting = new     ServiceReference1.Service1Client();
clientForTesting.GetDataCompleted += new EventHandler<ServiceReference1.GetDataCompletedEventArgs>(TestCallback);

&#61656; Complete TestCallBack method as follow,
   private void TestCallback(object sender, ServiceReference1.GetDataCompletedEventArgs e)
            MessageBox.Show( e.Result);
&#61656;  You are good to go now run, WCF project and then run windows phone 8 application.

&#61656;  Service will hit (break point added).
&#61656; By continuing you will get result as follow.

Hope you enjoyed this simple tutorial to run local web services on your windows phone.
Happy coding!

Helping Note:

&#61656;  Set inbounds of your private and domain to “allow”.
&#61656; Change ip if service does not hit. (In case of more than one accesses to network, if you see more than one ip’s while configuring your ip address by ipconfig command )

>  Inbound Error:

     If you are having Inbound error , that is basically due to firewall settings. To resolve this error do following steps.

1) GOTO Windows Firewall  ---- > Advance Settings ----- > Windows Firewall properties
2) Domain Profile --- > Inbound Connections ---- > Allow
3) Private Profile ----> Inbound Connections ----- > Allow

      Press OK

Leave a Comment
  • Please add 2 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Page 1 of 1 (1 items)