views:

520

answers:

1

I have a small WCF webservice working in my development environment (VStudio 2008, WinXP). I am appreciating being able to use the WCF Test Client at this stage of things.

Currently, the APP.CONFIG of my service (project) contains:

    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/Contracts/Service1/" />
      </baseAddresses>
    </host>

ASP.NET Web application projects expose a nice tab in the Project Properties with a radio button allowing you to easily choose:

  • Use Visual Studio Development Server (with specify or auto-assign port)
  • Use Local IIS Web Server (button for 'Create Virtual Directory')

I am confused about how to best go about configuring this project for use with my IIS localhost webserver. I definitely want to retain the ability to use the WCF Test Client. So much configuration seems to occur "behind the scenes" and I'm concerned about breaking my testing environment. Hope you can help me and suggest best practices for these objectives.

EDIT: Here is snippet of solution file as it is now:

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{BC414788-5E5B-4584-9350-B4DD6129665A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service\Service.csproj", "{252DE277-D864-4423-BED5-33A8B5ABCAB7}"
EndProject
+1  A: 

If you host your WCF service inside IIS, you'll need to create a virtual directory, and a "myservice.svc" file (there's tons of docs on how to do this).

In this case, your URL will be

http://localhost/(your virtual dir)/myservice.svc

and whatever is in the app.config file will be ignored.

WcfTestClient and all those neat tools should continue to work just fine.

Marc

PS: Cwoo has a great link there - actually, Aaron Skonnard has a whole slew of introductory and advanced videos on WCF. You might want to check them out at the "Endpoint TV" show on Channel 9 - loads of good stuff!

PPS: or go here to the Pluralsight screencast section and click on the "WCF Basics" tag in the cloud to get the more basic WCF screencasts to get you started - excellent stuff!

marc_s
I know how to do the above things (plus I will need a web.config) but what about my existing project's source code which exists in a solution at: C:\Documents and Settings\johna\My Documents\Visual Studio 2008\ProjectsIf I understand you correctly, I need to start over with another VStudio solution/project and "copy" stuff I've written to a new project configured differently?
John Galt
No, not at all - just keep using it. That's the beauty of WCF - you can write your actual service code ONCE, and then deploy it to various scenarios and use various bindings just be changing config settings.
marc_s
Is your service code currently in what - a class library? Excellent! Just set up a new web site or web app (your pick), and then reference that class library from the web site/app, add the *.svc file - you're done! It's THAT simple.
marc_s
Thanks marc_s, I am still a little confused. Appears I DO have to "start over" with some sort of new VStudio2008 project. Then have the new project "reference" the WCF service library projects..how to do that confuses me. Do I "add reference" to the bin (.dll) of the current project or what? Please note my EDIT update to original post where I've pasted part of my SOLUTION file. Thanks so much for your patient help.
John Galt
I was trying to do this 2 days ago too :o Here's the video I followed. http://mschnlnine.vo.llnwd.net/d1/ch9/7/6/1/1/2/4/hosting_wcf_services_in_iis.wmv
Cwoo
Well, if you want to host your service in IIS, you have to have some form of a web project, yes - either a web site or a web application. And yes, you would add a regular project reference to your web app (right click on project, "Add Reference") - that's all.
marc_s
Thank you so much...the video is VERY useful .. looking at it now and it spells out exactly what you said to do. Case closed...you are the man! Many thanks!
John Galt