Search code examples
.netwcfwindows-services

WCF soap webservice as Windows service can't be reached


I have a .NET 4.6 application that hosts a WCF soap webservice. It's pretty basic and it works fine when I run it in a classic .NET 4.6 desktop application under my own user. However I want to run it as a Windows service under a service account. I use 100% the exact same wcf code and service definition with the only difference that it's within a windows service, but it doesn't work. No response is returned.

So for example in a .NET 4.6 desktop application I can send POST soap requests and get replies, and browse the definition on http://10.10.10.10:8904/blabla?wsdl just fine. When I run it as a Windows service under a service account, it doesn't respond. For example browsing to http://10.10.10.10:8904/blabla?wsdl doesn't give any response (in the browser it keeps spinning).

In netstat I can see Windows hosting on the port 8904.

If I enable WCF tracing to file I can see logs like this, so there seems to be some WCF activity at least:

<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord">
    <ActivityName>Ontvang bytes op verbinding http://10.10.10.10:8904/blabla?wsdl.</ActivityName>
    <ActivityType>ReceiveBytes</ActivityType>
</ExtendedData>

I have also already added: netsh http add urlacl url=http://+:8904/blabla/ user=Everyone

Any idea? Am I missing certain user rights? Does there need to be a WCF configuration difference between running as a desktop application and a windows service?


Solution

  • The solution was to start the service from within a separate thread, and not from the main thread. Otherwise it locks up.