I have a WCF service application. I want to access this service via http request on web browser.
When I run the WCF service on IISExpress, it works but when I published the service on IIS, returns 404 error. How can I fix this issue?
IService.cs
namespace Protek.WebService
{
[ServiceContract]
public interface IService
{
[WebGet(UriTemplate = "HelloWorld")]
[OperationContract]
string HelloWorld();
}
}
Service.svc
<%@ ServiceHost Language="C#" Debug="true" Service="Protek.WebService.Service" CodeBehind="Service.svc.cs" %>
Service.svc.cs
namespace Protek.WebService
{
public class Service : IService
{
public string HelloWorld()
{
return "Hello World";
}
}
}
Web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DefaultBehavior" name="Protek.WebService.Service">
<endpoint address="ws" binding="wsHttpBinding" contract="Protek.WebService.IService"/>
<endpoint address="" binding="webHttpBinding" contract="Protek.WebService.IService" behaviorConfiguration="WebBehavior"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:5858/Service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>