I am not sure if I am about to ask a noddy question, but here it goes. I have a WCF service hosted in a Windows service and a new requirement has come in: A keepalive web page necessary for load balancing. Is it possible to host this page from my Windows servi开发者_如何学编程ce?
Do I need to resort to hosting the WCF service in IIS? I would prefer not to do this.
Thank you.
Try to create a service contract to handle the requests of the loadbalancer exposed using a basicHttpBinding
Your windows service may expose an HTTP endpoint by basicHttpBinding or wsHttpBinding. IIS is not required. To host an HTTP endpoint via IIS has some benefits though like message based activation.
And if IIS is already running on the same machine be sure to pick a port different from 80 for your windows service HTTP endpoint since IIS will listen to requests on port 80 and then the requests wouldn't reach your service.
More than one year later, I hope this can help
http://msdn.microsoft.com/en-us/library/bb412178.aspx
How to: Create a Basic WCF Web HTTP Service
Look at the contract:
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet]
string EchoWithGet(string s);
[OperationContract]
[WebInvoke]
string EchoWithPost(string s);
}
you have the request (or post request) in 's' param and you must write the output html in the return. That's all
精彩评论