开发者

Basic HTTP service with IIS but without WCF

I am looking for a way to host a very basic, but high performance, HTTP service that integrates with IIS using .Net.

I h开发者_Go百科ave considered the option of using HttpListener but I doubt its performance and also we are going to run many services that are all listening on the same port.

Actually, if it were possible to have a WCF endpoint that will catch any request with a url that starts with that endpoint, but may end with anything, this could be a solution.

I am building a Client library that will encapsulate a custom protocol with custom metadata endpoints, custom discovery endpoints and resources. The idea is that the Client library will make the associations between endpoints and resources(/other endpoints) automatically, so the use of WCF is not possible as this mapping will be unknown at compile time.

Another reason is that we're going for a direction of platform independence and we want the option to easily replace IIS with Apache in the future.

Thanks!


I think that you could still use WCF for your service. In terms of hosting outside of IIS you have options:

http://msdn.microsoft.com/en-us/library/ms730158.aspx

Also, your client can build it's bindings and endpoints at run-time. So details do not need to be specified in your .config's system.serviceModel section . Everything that can be specified in the .config can be done in code as well.

[Edit] You don't have to "specify" every endpoint to WCF. if you know the address at runtime simly pass it through to the code that creates your service proxy. Have a look at the ChannelFactory class, you can pass it a binding (which again you can get from config, or bulid at runtime) and an endpoint ( the endpoint is created very simply by providing the address) here is an example method that will create a service proxy of type T. In the example below the endpoint address is coming from .config but you could pass it in from anywhere in your code.

    /// <summary>
    /// Creates a service proxy from a binding name and address
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public static T Create<T>()
    {
        string endpoint = ConfigurationManager.AppSettings["FactoryEndPointAddress"];
        string bindingname = ConfigurationManager.AppSettings["FactoryBindingName"];
        var address = new EndpointAddress(endpoint);
        var factory = new ChannelFactory<T>(GetBinding(bindingname), address);
        return factory.CreateChannel(address);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜