tags:

views:

98

answers:

1

Hi,

Is there a way to expose a service from a single endpoint like "https://mydomain.com/Myservice.svc" but to be able to have differents binding configuration.

I know that a endpoint must be unique on URL + Contract + Binding, but I wonder how can I have multiple bindings without coping all the .svc files for every bindings that I whant to support (since a URL in IIS is a folder or a virtual directory)

In example, I want to have Http with encryption, Http without encryption.. If later I whant no securityContext to be established, than I have to copy 4 times my svc files to support

One with : establishSecuriTyContext = true Encryption = true

One with : establishSecuriTyContext = true Encryption = false

One with : establishSecuriTyContext = true Encryption = true

One with : establishSecuriTyContext = false Encryption = false

and so on....

It don't makes sense to me.

A: 

Reference a unique binding configuration for each endpoint. This example shows how to do it with the NetNamedPipeBinding, but you can extend the concept to other bindings as well.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <netNamedPipeBinding>
                <binding name="default1" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
                    transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
                    maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="Transport">
                        <transport protectionLevel="EncryptAndSign" />
                    </security>
                </binding>
                <binding name="default2" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="infinite" sendTimeout="00:01:00" transactionFlow="false"
                    transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
                    maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="Transport">
                        <transport protectionLevel="EncryptAndSign" />
                    </security>
                </binding>
            </netNamedPipeBinding>
        </bindings>
        <services>
            <service name="MyService">
                <endpoint name="MyService1"
                    address="net.pipe://localhost/MyService1"
                    contract="NSITE.Services.Event.IMyService"
                    binding="netNamedPipeBinding" bindingConfiguration="default1" />
                <endpoint name="MyService2"
                    address="net.pipe://localhost/MyService2"
                    contract="NSITE.Services.Event.IMyService"
                    binding="netNamedPipeBinding" bindingConfiguration="default2" />
            </service>
        </services>
    </system.serviceModel>
</configuration>
Matt Davis
Hi Matt,I'm not very familiar with NamedPipeBinding... Do you have .svc files ?Basically, I want to do exactly this, but in IIS hosted HTTP/HTTPS binidngs, the starting point of a service is a .svc file. In your example, in the address of your endpoints, /MyService1 and /MyService2 would be two directory in IIS.But I don't want to copy the .svc files the number of times that I have different bindings. Since my Web project is precompiled, I can't just make two IIS virtual directory, since a precompiled web project is tightly bind with it's IIS application.Any ideas ?
Sebastien
@Sebastien, the address/binding/contract tuple for each endpoint must be unique. If the contract is the same and the binding is the same, then the address <i>must</i> change in order for the tuple to be unique. I don't work within IIS, but if address for a .svc file maps to a directory, it sounds like you'll have to have multiple directories. I wish someone who knows a little more about the IIS side of things could help you out.
Matt Davis