07.25
I recently made a WCF Service for the company i work for. I had it all working on my own computer so it was about time to put the service online.
This proved to be pretty difficult, the more because Microsoft doesn’t realy give a good explanation on MSDN about how to do this.
I struggled about a day to get it right. Mostly because i’m not as witty as the people down in Redmond though.
Anyway; i’ll give you a step-by-step overview on how to get your code working on a live server in the hopes of saving atleast one person a headache.
First of all it’s a good idea to make it work on your local computer. This will save you some trouble of uploading to your server and rdp’ing constantly.
What you’ll need:
- IIS 7 installed along with all the WCF features
- Visual Studio 2008
- Your WCF service; compiled in “Release”
- A fair amount of optimism
As you can see in the tutorial on MSDN they expect you to manually create an App_Folder and put your script files in there. Allthough it’s a complete valid way (or is it? do we like to have .cs files to mess around with?) of working, i think us programmers will rarely handle it this way.
Most likely you will have built your Service in Visual Studio, added a seperate consuming client in the same solution and it magically works. When you want to deploy all of it live things are quiet different and chances are that your client application won’t be on the same server as well.
So here’s what we’ll do:
Setting up the WCF Service in IIS7:
Start off by creating an application pool for your Service in IIS7
Next we’ll create the folder in which the service will reside. Make sure IIS_IUSRS has “Read & Execute “, “List folder contents” and “Read” on this folder. (i took C:\myservice as folder)
Now we’ll create a new Website in IIS and we’ll make it point to our freshly created folder
I put the port on 8000 as to not interfere with the website traffic that’s passing along through gate 80.
Now this will not work yet because we need to activate WCF for IIS7 manually. This we will do by running the following command in cmd:
“%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe” -r -y
We’re done configuring IIS!
Preparing our Webservice to be served in IIS:
Navigate in your Windows Explorer to the folder you created for hosting the service in. Create a folder named “Bin” and copy your .dll files into that folder.
(C:\myservice\Bin in my case)
Navigate back to your folder (the parent of your new Bin folder that is) and create a file called yourservice.svc (replace yourservice with.. you know.. your service name).
I did this by creating a .txt file and changing the extension to .svc .
I know this is a bit weird but it’s the way to go.
In your .svc file you can copy this:
<% @ServiceHost Service=”YourServiceNameSpace.YourServiceName” %>
Change the Service attribute accordingly to your needs ofcourse.
That’s all that has to come inside the .svc file.
Next, create a web.config file in the same folder as the .svc file and edit it:
Change this according to your namespace and service name ofcourse.
And finally, if you did it all correctly, you should be able to surf to http://localhost:8000/yourservice.svc and you should arrive on the webservice page.
This means total and utter succes.
If i have made any mistakes or forget to mention anything please let me know.



No Comment.
Add Your Comment