Welcome to MSDN Blogs Sign in | Join | Help

Hosting a WCF Service in Cassini

If you want to test your WCF Service quickly, without using IIS, you can use the built in Web Server (aka Cassini). There are some limitations but it will work.

The limitation is that Cassini assigns a new HTTP port number on every instance of the web server. This means that every time you shut down the Cassini instance, running the project will create a new web server instance with a new port and invalid your endpoint. The trick is to not shut down your Cassini instance.

Of course the recommendation is to use IIS for more robust testing.

These are quick instructions. (I am assuming you know how to create a basic WCF service  library in VS 2005 and are familiar with the VS environment)

  • Create you WCF Library in VS 2005
  • Add a new ASP.NET project to the solution. Make sure it is not an IIS ASP.NET project and is file based.
  • Add a new text file to the project. Call it Service.svc.
  • Add the following to the svc file.

<%@ServiceHost language=c# Debug="true" Service="YourServiceLibraryName.YourServiceName" %>

  • In the Web.Config file add the bindings

<system.serviceModel>

    <services>

      <service name="YourServiceLibrary.YourServiceName">

        <!-- use base address provided by host -->

        <endpoint address="" binding="wsHttpBinding" contract="YourServiceLibrary.IYourServiceName"/>

      </service>

    </services>

  </system.serviceModel>

  • Now set the ASP.NET project as the start up project and run the project. IE should open and you should see the WCF Service page.
  • Now examine the WSDL by clicking on the wsdl link. Find the <wsa:10 Address>  towards the end of the document. This will give you the address of the service for your client to call into. (Cassini will update the port every time the web server turns on. So make sure you don’t kill the web server instance).
  • Use that endpoint in your client to test the service.

Remember ... as long as the you don't close the Cassini instance the endpoint port remains the same and the client should work.

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Published Friday, June 30, 2006 9:40 AM by nagrajn

Comments

No Comments
Anonymous comments are disabled
 
Page view tracker