connect to a local web service from the Windows Phone 8 emulator – Resolving the issues


  • This article resolves the issues that come across when we try to consume a web Service from our Windows Phone 8 Emulator.

When you create a WCF web service in Visual Studio, by default the service is hosted in IIS Express and only accepts connections at http://localhost/. Apps that target Windows Phone OS 7.1 can connect to the development computer as localhost because the Windows Phone 7.1 emulator uses the network connection of the development computer. The Windows Phone 8 Emulator, however, configures itself as a separate device on the network. As a result, an app running on the Windows Phone 8 Emulator can’t connect to the development computer as localhost.

All the relevant Details about this can be found at the following link

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx#BKMK_Settingupprojectstodemonstratetheproblemandthesolution

But the Problem is that this solutions too gives problems and the emulator won’t consume a web service, just yet,

but fortunately, one of our brilliant interns here at MIC Lahore, Saad Mahmood, has come up with a solution that can help resolve the isssues.

When you intend to consume a web service, you generally come across the following exception, 

 

 

for a resolution,

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

 

 

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

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.

  • Run CMD as administrator and type this command
  • Netsh http add urlacl url = http://<your ip> : <port>/ user = everyone
  • This will result in “Reservation successfully added”

You can Follow the steps in the Blog Post by Saad Mahmood on the following Link

http://blog.procesium.us

 

 

 

 

 

 

 

Comments (19)

  1. Alfred Alston says:

    A single command resolves the issue in real.

  2. Clayton Barry says:

    works fine !

  3. Clarence Bert says:

    worked!

  4. Ali Siddiqui says:

    Sir , Thanks for giving solution, I've been following many articles for this purpose. It worked!

  5. Zafar Ali says:

    can  someone give me more assistance?

  6. Asad Saeed says:

    Works for WP8 Emulator!

  7. Abeer Sohail says:

    Easy to apply and works perfectly fine.

  8. Zafar, what is that you are seeking please? You can drop an email directly to the mentioned personals or leave your issue in comment here. We'll be glad to be of any help.

  9. Zafar Ali says:

    In Bounds error. I'm having.

  10. Saad Mahmood says:

    I was through this stage while resolving this issue. I fond in bounds error, it was due to my firewall settings.

    may be I am wrong but what I believe it that this must resolve your issue ,

    GOTO Windows Firewall  —- > Advance Settings —– > Windows Firewall properties

    Domain Profile — > Inbound Connections —- > Allow

    Private Profile —-> Inbound Connections —– > Allow

    Press OK

    hope it resolves the issue

    regards,

  11. Clarence Bert says:

    Better to include this information in the very reference blog as a note or helping material.

  12. Zafar Ali says:

    Resolved , Thanks

  13. David Christian says:

    Good Style to resolve it.

  14. Good Effort says:

    Keep it up

  15. Mark says:

    Having Problem

  16. Saad Mahmood says:

    I would love to know about your issue, kindly visit the blog , drop me an email with snapshot of regarding issue or describe the very issue here.

    regards,

  17. Shveta says:

    I am having issues , help me ASAP please.

  18. Iren Wang says:

    It works!!

  19. sidra says:

    I am having issues again same exception was found 🙁