Create a WCF library¶
To create a library of test WCF follow the following steps:
- Create a new "WCF Service Library" under VS2008.
- Delete the generated classes Service1.cs and IService1.cs.
- Clean your App.config to look like the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
</services>
<behaviors>
<serviceBehaviors>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
</services>
<behaviors>
<serviceBehaviors>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
- Right click on the project and choose Add-> New Item "; choose to add a" WCF Service "and call it" HelloWorld "
- Change the file HelloWorld.cs IHelloWorld.cs and so they look like this:
[WebGet(UriTemplate="SayHello/{inputName}")]
[ServiceContract]
public interface IHelloWorld
{
[OperationContract]
string SayHello(string inputName);
}
public class HelloWorld : IHelloWorld
{
#region IHelloWorld Members
public string SayHello(string inputName)
{
return "Hello " + inputName;
}
#endregion
}
* Build the project (with a "Strong name") and put the assembly in the GAC("%windir%\assembly\").