Yes we can implement multiple contracts by single service.
Like in csharp a single class can implement multiple Interfaces Here also same.
But single proxy(Reference only created at client).
File--new---wcf service Application ----one wcf application is created with .svc
now our service has two Interfaces(IService1,IJob) which are implemented in Service1.svc file means
both are implemented at Service1.cs
as per same base address:
yes both IService1, IJob both uses same base address
run the service
at client:
after adding the servicenece as per 2 contracts (IService1,IJob) then 2 times same configuratiion will be generated at client.
in wcf 4.0 which is rectificted at client(with simplified configuration).
but client immediate window
as per binding confiuguration for the contract we can able to know. what is contract
how many operations with that contract?
what is the contract is implmented .....see above image.
Every contract(IService1, IJob) requires an relavent endpoint for communication. the schema(http) is same for all of same types like WsHttpBinding, BasicHttpBinding....ect enough a single base address.
again when the binding is different : like netTcpbinding choose----> different choose
different base address. like
<system.serviceModel>
<services>
<service behaviorConfiguration="WcftcpServiceLibrary1.Service1Behavior"
name="WcftcpServiceLibrary1.Service1">
<endpoint address="net.tcp://localhost:8732/Service1/first" binding="netTcpBinding" bindingConfiguration=""
contract="WcftcpServiceLibrary1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="/first" binding="basicHttpBinding" bindingConfiguration=""
contract="WcftcpServiceLibrary1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="/second" binding="wsHttpBinding" bindingConfiguration=""
contract="WcftcpServiceLibrary1.IService1"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Service1/"/>
<add baseAddress="net.tcp://localhost:8732/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcftcpServiceLibrary1.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
wsHttpBinding &&& basicHttpBinding using
<add baseAddress="http://localhost:8733/Service1/"/>
netTcpBinding using
<add baseAddress="net.tcp://localhost:8732/Service1/" />
Note: the relavent binding configurations are generated automatically based on binding. the generated bindings are have their approarte binding default values like
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8732/Service1/first" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="IService1"
name="NetTcpBinding_IService1">
<identity>
<dns value="localhost" />********************
</identity>
</endpoint>
<endpoint address="http://localhost:8733/Service1/first" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="IService1"
name="BasicHttpBinding_IService1" />
<endpoint address="http://localhost:8733/Service1/second" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="IService1"
name="WSHttpBinding_IService1">
<identity>
<userPrincipalName value="kasibabu_p@zolt.dc" />********************
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
File--new---wcf service Application ----one wcf application is created with .svc
now our service has two Interfaces(IService1,IJob) which are implemented in Service1.svc file means
both are implemented at Service1.cs
as per same base address:
yes both IService1, IJob both uses same base address
run the service
at client:
after adding the servicenece as per 2 contracts (IService1,IJob) then 2 times same configuratiion will be generated at client.
in wcf 4.0 which is rectificted at client(with simplified configuration).
but client immediate window
as per binding confiuguration for the contract we can able to know. what is contract
how many operations with that contract?
what is the contract is implmented .....see above image.
Every contract(IService1, IJob) requires an relavent endpoint for communication. the schema(http) is same for all of same types like WsHttpBinding, BasicHttpBinding....ect enough a single base address.
again when the binding is different : like netTcpbinding choose----> different choose
different base address. like
<system.serviceModel>
<services>
<service behaviorConfiguration="WcftcpServiceLibrary1.Service1Behavior"
name="WcftcpServiceLibrary1.Service1">
<endpoint address="net.tcp://localhost:8732/Service1/first" binding="netTcpBinding" bindingConfiguration=""
contract="WcftcpServiceLibrary1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="/first" binding="basicHttpBinding" bindingConfiguration=""
contract="WcftcpServiceLibrary1.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="/second" binding="wsHttpBinding" bindingConfiguration=""
contract="WcftcpServiceLibrary1.IService1"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Service1/"/>
<add baseAddress="net.tcp://localhost:8732/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcftcpServiceLibrary1.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="false"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
wsHttpBinding &&& basicHttpBinding using
<add baseAddress="http://localhost:8733/Service1/"/>
netTcpBinding using
<add baseAddress="net.tcp://localhost:8732/Service1/" />
Note: the relavent binding configurations are generated automatically based on binding. the generated bindings are have their approarte binding default values like
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="NetTcpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8732/Service1/first" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="IService1"
name="NetTcpBinding_IService1">
<identity>
<dns value="localhost" />********************
</identity>
</endpoint>
<endpoint address="http://localhost:8733/Service1/first" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="IService1"
name="BasicHttpBinding_IService1" />
<endpoint address="http://localhost:8733/Service1/second" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="IService1"
name="WSHttpBinding_IService1">
<identity>
<userPrincipalName value="kasibabu_p@zolt.dc" />********************
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
No comments:
Post a Comment