Last post Sep 02, 2014 07:07 AM by Jitendra_Dotnet
Sep 02, 2014 07:07 AM|Jitendra_Dotnet|LINK
We all facing problems to test WCF service in our local environments, generally in iPhone, Android and all other mobile device. I also came across with this issue recently. I have created WCF service for mobile app and I want to test it with
app (iPhone, Android) but problem I have faced it that I doesn’t have Hosting Server to host my WCF service and I must have to do this with my Local service (Local iis/ localhost). Here is the solution for the same and we can use our localhost to test WCF
service in iPhone and Android.
Here I will present some good solution to our all developer to host WCF service on localhost and access via Internet and access the same on iPhone and Android. It’s pretty simple and straight forward.
First you should create WCF Service using this article -http://mikesknowledgebase.azurewebsites.net/pages/Services/WebServices-Page1.htm and
then continue follow this article. I assume that now you have WCF service created with your local machine (running successfully) and you are looking for host the same in local IIS. All right, first go to IIS and create Application under Default Web Site (Right
click on Default web site and “Add Application”) – Review Step-1 snap shot.
Step - 1
Now give alias for your virtual directory and set path from your local drive (Review step-2 snap shot)
Make sure your default app pool set to .NET CLR V4.0 (review step-3 snap shot). Now all done, your WCF service is not hosted on Localhost.
Step - 3
You can test it using browse (review step-4 snap shot).
Step - 4
Your WCF service is not running successfully on localhost (Review step – 5 snap shot).
Step - 5
To access the same via LAN (Local Area Network) you must disable Firewall for you Private networks (Make sure you have to just disable private network not public). Test your WCF service across the LAN and see are you able to test
it on another computer? Yes hopefully you are doing well.
Now we have WCF service and it is running on localhost on your machine as well as over LAN. Now we have to test/ consume the same on iPhone/ Android/ Any mobile device app, it’s pretty simple. Follow below steps.
1. Go to ngrok.com, download the archive and extract it to wherever you’d like ngrok to live on your computer.
2. Open up a command line terminal and go to the folder you extracted ngrok to. Run the following command to create a tunnel to your localhost on port 80: ngrok 80
3. You’ll see a screen like so:
4. In the example above, we’ve got our temp URL (http://3dfab6bf.ngrok.com) being forwarded to our localhost on 127.0.0.1:80.
Ahh, all process now done!! Above url is your temporary URL to use via internet to access your LocalHost anywhere. You should use it on iPhone app (code behind to call wcf service) or run the same on browser or consume it on any other app using URL above.
Note: It’s not permanent solution but you should test your WCF service using above scenario – using localhost. The address of ngrok will change every time when you run using command prompt.
Hope have got solution from this article.