In WCF the relationship between Address, Contract and Binding is called Endpoint. The Endpoint is the fusion of Address, Contract and Binding. WCF formalizes this relationship in the form of an endpoint.
Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service
(追記) (追記ここまで)Configuring an endpoint administratively requires placing the endpoints in the hosting process' config file. For example, given this service definition:
namespace endname
{
[ServiceContract]
interface IMyContract
{...}
class MyService : IMyContract
{...}
}
<system.serviceModel> <services> <service name="MyNamespace.MyService"> <endpoint address="http://localhost:8000/MyService/" binding="wsHttpBinding" contract="MyNamespace.IMyContract"/> </service> </services> </system.serviceModel>
<servicename="MyService"> <endpoint address="http://localhost:8000/MyService/" binding="wsHttpBinding" contract="IMyContract"/> <endpoint address="net.tcp://localhost:8001/MyService/" binding="netTcpBinding" contract="IMyContract"/> <endpoint address="net.tcp://localhost:8002/MyService/" binding="netTcpBinding" contract="IMyOtherContract"/> </service>
<system.serviceModel> <services> <service name = "MyService"> <endpoint address = "net.tcp://localhost:8000/MyService/" bindingConfiguration = "TransactionalTCP" binding = "netTcpBinding" contract = "IMyContract"/> <endpoint address = "net.tcp://localhost:8001/MyService/" bindingConfiguration = "TransactionalTCP" binding = "netTcpBinding" contract = "IMyOtherContract"/> </service> </services> <bindings> <netTcpBinding> <binding name = "TransactionalTCP" transactionFlow = "true"/> </netTcpBinding> </bindings> </system.serviceModel>
ServiceHost host = new ServiceHost(typeof(MyService)); Binding wsBinding = new WSHttpBinding( ); Binding tcpBinding = new NetTcpBinding( ); host.AddServiceEndpoint(typeof(IMyContract),wsBinding, "http://localhost:8000/MyService"); host.AddServiceEndpoint(typeof(IMyContract),tcpBinding, "net.tcp://localhost:8001/MyService"); host.AddServiceEndpoint(typeof(IMyOtherContract),tcpBinding, "net.tcp://localhost:8002/MyService"); host.Open( ); </system.serviceModel>
AddServiceEndpoint( ) It adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address.
(追記) (追記ここまで)Others
Languages
Frameworks
Web / Design
Mobile Technology
Sql & Technology
R4R