[Solved] WCF (.svc) On Server2016 Docker Container

##Anyone using WCF in a container ?

Expected behavior

ASPNet WCF Service should respond, but is not recognised.

Actual behavior

[WebException: The remote server returned an error: (404) Not Found.]
System.Net.HttpWebRequest.GetResponse() +1743
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +75

[EndpointNotFoundException: There was no endpoint listening at http://localhost/MyWcfService/Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]

Information

I have a simple WCF web application which does not work on a Windows Server 2016 Container.

What I think the problem is that .svc handler mapping is missing… see
WCF on IIS8; *.svc handler mapping doesn’t work

When I try to add the handler using

Add-WindowsFeature 'NET-HTTP-Activation'	 

or

dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation

I get this error:

The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For
more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

Doing this makes no difference:

Dism /Online /Cleanup-Image /RestoreHealth	

It feels like I must be doing the wrong thing if I need to setup a source for DISM.

Any Ideas ?

Steps to reproduce the behavior

  1. Create a WCF web application
  2. Make it available in a Windows Server 2016 Container, built from microsoft/iis.
  3. Make a call to it using a client.

The container was built using the following dockerfile:

FROM microsoft/iis
RUN powershell add-windowsfeature web-asp-net45
COPY . c:/install
WORKDIR c:/install/
SHELL ["powershell", "-command"]

# remove default web site, add my wcf web application
RUN Remove-WebSite -Name 'Default Web Site'; \ 
	New-Website -Name 'my-app' -Port 80 -PhysicalPath 'C:\install' -ApplicationPool '.NET v4.5'

ENTRYPOINT powershell

You probably need to add WCF HTTP activation feature as well

“net-wcf-http-Activation45”

Thanks, but even doing this first, when I try to “Add-WindowsFeature NET-HTTP-Activation” I still get the same “The source files could not be found” error.

I don’t use dockerfile to build my systems and instead write powershell DSC scripts and run them and worked for me since it’s easier to debug.
Here is mine below. Just save as PS1 file and use it as CMD. It did the trick for me since I also run same WCF application. Also will help you with package management question you have on the other thread. Instead of the ugliness of dockerfile it’s much cleaner way IMHO.

Configuration BasicIIS
{
   Import-DscResource -ModuleName 'PSDesiredStateConfiguration' 
   node localhost {
         WindowsFeature IIS
        {
            Ensure = "Present"
            Name = "Web-Mgmt-Service"
        }
        WindowsFeature HTTPWCF
        {
            Ensure = "Present"
            Name = "net-wcf-http-Activation45"
        } 
        Service WebManagementService
        {    
            Name = "WMSVC"
            StartupType = "Automatic"
            State = "Running"
            DependsOn = "[WindowsFeature]IIS"
        }
        Registry RemoteManagement
        {
            Key = "HKLM:\SOFTWARE\Microsoft\WebManagement\Server"
            ValueName =  "EnableRemoteManagement"
            ValueData = 1
            ValueType = "Dword"
            DependsOn = "[WindowsFeature]IIS"
        }
        Script PackageProvider   
        {
            SetScript = {Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force}
            TestScript =  {if ((Get-PackageProvider -listavailable -name nuget -erroraction SilentlyContinue).Count -eq 0) {return $false} else {return $true}}
            GetScript = {@{Result = "true"}}       
        }
        Script xWebAdministration
        { 
            SetScript = {Install-Module xWebAdministration}
            TestScript =  {if ((get-module xwebadminstration -ListAvailable).Count -eq 0){return $false}else {return $true}}
            GetScript = {@{Result = "true"}}
            DependsOn = "[Script]Packageprovider"
        }
        WindowsFeature WindowsDefenderFeatures
        {
            Ensure = "Absent"
            Name = "Windows-Defender-Features"
            IncludeAllSubFeature = $true
        }
    }
}

BasicIIS -OutputPath .\BasicIIS
Start-DscConfiguration -Wait -Verbose -Path .\BasicIIS -Force

Thanks, it worked :grinning:, I didn’t know about DSC (I’m a Docker / Powershell noob).