One endpoint, different bindings?
Is there a way to expose a service from a single endpoint like "https://mydoma开发者_运维知识库in.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.
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>
精彩评论