views:

1431

answers:

3

Hi all,

I'm trying to run a WCF ServiceHost as an NT Service on a Windows 2007 SP1 Server. The ServiceHost is reponsible for hosting a single service endpoint: a basicHttpBinding with the following address:

http://localhost:5555/ToBlah

When I run this ServiceHost on my local machine (Windows XP), it works fine - when I POST a SOAP message to it, I get back an HTTP 202 code ("Accepted"), which is the correct response for my service because the contract has IsOneWay=true. However, when I run this on my 2007 server, I get 503 errors when I try to call the service. I have the WCF message logging turned "all the way up," but I'm not seeing any logging whatsoever, which leads me to believe that this is happening at a lower level than WCF (the call never gets to the WCF "layer").

The sys-admins and I have tried various forms of httpcfg commands, but no luck so far.

I know trying to host this in IIS might be a possible solution, but our production app server does not have IIS installed, so I would like to just run the service as a ServiceHost.

Any ideas would be greatly appreciated!

+1  A: 

What identity is configured for the NT service? To isolate the problem, try using a local-admin account to see if this problem is permission related.

driAn
Thanks for the suggestion, I'll look into that tomorrow.
Andy White
+1  A: 

It seems to me that either a firewall on the server or another configuration setting is blocking the port.

If not, then your service may be experiencing an error during the creation of the ServiceHost object instance or during the creation of the service endpoint, and the error is for some reason not trapped(?). You could write some simple internal test loop within the service code to verify that the service endpoint was created correctly. That might reveal something interesting.

Additionally, running a client from that server and connecting to your service that is running on the development machine might tell you something more? You could use WCFTestClient.exe, as referenced here: http://stackoverflow.com/questions/484717/error-externally-testing-wcf-udp-custom-transport-channel-sample-from-the-windows. That might give you additional information. However, you will need to support MetadataExchange (Mex) in your service in order to use that test client.

Alternatively, you could use the WCF samples from the Visual Studio 2008 Samples folder, combined with WCFTestClient.exe to test some services that are self-hosted and are expected to work correctly, first within the server and then from outside of the server.

EnocNRoll
Thanks for taking the time to help me. I'm definitely going to look into your suggestions.
Andy White
+2  A: 

Well, I still can't get it to work on the Vista servers - it's still giving 503 errors, but I ended up getting it setup on a Windows 2003 server, and it seems to be working now.

One thing I did learn in this process was the use of HttpCfg.exe to allow a user to open a non-standard HTTP port.

Basically I had to run something like the following command:

httpcfg.exe set urlacl /u http://+:5555/ /a "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"

You can then view the URL ACL settings with this command:

httpcfg.exe query urlacl

On Vista, you can run the same types of commands using netsh (see link below).

Sadly, this took awhile to figure out, but it was a good learning experience.

Here are some links that I thought were useful in figuring this out:

Andy White
Hey, that's great info about server limitations on custom HTTP ports. I have had fine experience using custom HTTP ports on XP Pro, so it's an interesting difference. Please post your Vista success later, and vote us up if any of our ideas were helpful.
EnocNRoll
Your input really helped me work through this, so I voted up your answer too. If I ever figure out the issue on the vista server, I'll post again. Thanks.
Andy White