Visual Studio.NET - WCF Test Service (SVC)
Here is the sample source code for WCF Test Service.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace Wcf_Test_Service
{
public class TestService : ITestService
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace Wcf_Test_Service
{
[ServiceContract]
public interface ITestService
{
[OperationContract (Name="int")]
string GetData(int value);
[OperationContract(Name = "string")]
string GetData(string value);
}
}
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Here is how hosting is done in ASP.NET development server in development machine.
Here is how it looks like in IE.
Click here to download the SCF Test Service Library (DLL) Source Code
|