Hi Friends ,
in this article i will explain about the Binding
and Behaviour of WCF. It is one of the fundamental of WCF.In previous article i already explained about Fundamentals of WCF.
Suppose we have to create the service for two clients ,one client will access SOAP using HTTP and second client access Binary using TCP.
Binding and behaviour:
Binding
represents how the client can communicate with the service.
We can know
this with the small example.
Suppose we have to create the service for two clients ,one client will access SOAP using HTTP and second client access Binary using TCP.
Using
webservice it is impossible but using WCF we can do by adding extra endpoint in
the configuration file. i.e. in web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true"targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="MathService"
behaviorConfiguration="MathServiceBehavior">
<endpoint
address="http://localhost:9080/Service1.svc"contract="IMathService"
binding="wsHttpBinding"/>
<endpoint address="net.tcp://localhost:8080/MyService/MathService.svc"
contract="IMathService"
binding="netTcpBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false
and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
|
In the below example i explain about the Behaviour at the
service level. In the service behavior
I have mention the servieMetadata
node with attribute httGetEnabled='true'.
This attribute will specifies the publication of the service metadata.
Similarly we can add more behavior
to the service.
<system.serviceModel>
<services>
<service name="MathService"
behaviorConfiguration="MathServiceBehavior">
<endpoint address="" contract="IMathService"
binding="wsHttpBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MathServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
|
If you want to know contracts in WCF click on below link
"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook page Aspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog for more articles."
No comments:
Post a Comment