.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> WCF >> Post New QuestionBookmark and Share Subscribe to Forum

Can we create an http and tcp end points for the same service in WCF?

Posted By: Jean Paul     Posted Date: December 12, 2010    Points:2   Category :WCF
Can we create an http and tcp end points for the same service in WCF?

Responses
Author: Samrat Mohanta             
Posted Date: December 13, 2010     Points: 5   

Yes you can. You need to have different <baseAddress> and <endpoint> defined in the service configuration file. The example given below:

<service name="ConverterLibrary.TemperatureConverterService" behaviorConfiguration="ConverterLibrary.AllServiceBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8731/Design_Time_Addresses/ConverterLibrary/TemperatureService/" />
<add baseAddress = "net.tcp://localhost:8888/TemperatureService/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpoint name="WSHttpEndpoint" address ="" binding="wsHttpBinding" contract="ConverterLibrary.ITemperatureConverter">

<!--Duplex HTTP Binding-->
<endpoint name="WSDualHttpBinding"
address=""
binding="wsDualHttpBinding"
contract="ConverterLibrary.ITemperatureConverter">

<identity>
<dns value="localhost"/>
</identity>
</endpoint>

<!-- Metadata Endpoints -->
<endpoint name="NetHttpMetadataPoint" address="mexHttp" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint name="NetTcpMetadataPoint" address="mexTcp" binding="mexTcpBinding" contract="IMetadataExchange"/>

<!-- NET TCP Endpoints -->
<endpoint name="NetTcpEndPoint" address ="" binding="netTcpBinding" contract="ConverterLibrary.ITemperatureConverter"/>
</service>

In the client application configuration you need to create different endpoint bindings. The example given below:

<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpEndPoint" 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>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding" 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">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8888/TemperatureService/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ITemperatureConverter"
contract="TemperatureServiceReference.ITemperatureConverter"
name="NetTcpBinding_ITemperatureConverter">
<identity>
<userPrincipalName value="smohanta@PMINTL.NET" />
</identity>
</endpoint>
<endpoint address="http://localhost:8731/Design_Time_Addresses/ConverterLibrary/TemperatureService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding"
contract="TemperatureServiceReference.ITemperatureConverter"
name="WSDualHttpBinding">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8888/TemperatureService/"
binding="netTcpBinding" bindingConfiguration="NetTcpEndPoint"
contract="TemperatureServiceReference.ITemperatureConverter"
name="NetTcpEndPoint">
<identity>
<userPrincipalName value="smohanta@PMINTL.NET" />
</identity>
</endpoint>
</client>
</system.serviceModel>

Cheers....
Samrat Mohanta


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend