TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Post an article
Translate this page
Powered by
Microsoft® Translator
Wikis - Page Details
First published by
Saad Mahmood
When:
13 May 2013 1:49 PM
Last revision by
Payman Biukaghazadeh
(eMicrosoft Community Contributo)
When:
13 May 2013 9:19 PM
Revisions:
2
Comments:
1
Options
Subscribe to Article (RSS)
Share this
Can You Improve This Article?
Positively!
Click Sign In to add the tip, solution, correction or comment that will help other users.
Report inappropriate content using
these instructions
.
Wiki
>
TechNet Articles
>
Connecting local web service (WCF) from Windows Phone 8 Emulator
Connecting local web service (WCF) from Windows Phone 8 Emulator
Article
History
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,
Prerequisites:
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?
Solution:
 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
2) Netsh http add urlacl url =
http://<your
ip> : <port>/ user = everyone
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”
 Open “applicationhost.config” file in Notepad after searching it from start.
 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>
<sites>
<site> … </site>
</sites>
</application Host>
< /configuration>
 Change binding here as follow
< bindings>
<binding protocol="http" bindingInformation="*:60661:localhost" />
< binding protocol="http" bindingInformation="*:60661:<ip address>" />
</bindings>
Note : Use respective port number instead of 60661.
 Just replace the bindings with this code.
 After done! Save the file.
 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.
 If you will run
http://<yourip
>: 52335<your port>/ in a web explorer it will run as follow.
 Now the next step is to add the service to windows phone application.
 Search it by
http://<ip
address>/Service1.svc
 You’ll discover the web service and now your are ready to go.
 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);
clientForTesting.GetDataAsync(testValue);
}
 Complete TestCallBack method as follow,
private void TestCallback(object sender, ServiceReference1.GetDataCompletedEventArgs e)
{
MessageBox.Show( e.Result);
}
 You are good to go now run, WCF project and then run windows phone 8 application.
 Service will hit (break point added).
 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:
 Set inbounds of your private and domain to “allow”.
 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
8
,
Connecting CRM
,
emulator
,
en-US
,
has code
,
has Images
,
issue
,
local
,
services
,
WCF
,
web
,
Windows Phone
[Edit tags]
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.
Comments
Posted by
Payman Biukaghazadeh
on
13 May 2013 9:20 PM
Revision: edited tags
Edit
Page 1 of 1 (1 items)