I am using IIS 10 and Visual studio 2019. OS: windows 10
I have just created basic wcf web site (WCF Service Application). It's very simple, just a basic example.
I have tried to run this project in debug mode, with IIS express, running WcfTestClient. All good, wsdl is consumed from the link: http://localhost:62549/Service1.svc?wsdl
But, I need to publish this service to IIS. So, I've done publish with configuration:
All good, I see newly created application inside IIS.
But now, I can not get wsdl definition. Link: http://localhost/WcfService4/Service1.svc?wsdl
What am I doing wrong here?
Interface:
using System.ServiceModel;
namespace WcfService4
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
}
Class:
namespace WcfService4
{
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
}
Markup:
<%@ ServiceHost Language="C#" Debug="true" Service="WcfService4.Service1" CodeBehind="Service1.svc.cs" %>
Web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetadataBehavior" name="WcfService4.Service1">
<endpoint address=""
binding="basicHttpBinding"
contract="WcfService4.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
The reason for this error is that http activation is off in the windows features, you can turn it on in control->programs and features, select “Turn Windows features on or off”, then turn HTTP Activation on in your .net framework version advanced service.