Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the "behaviorConfiguration" attribute of service?

Tags:

what is the "behaviorConfiguration" attribute of service?

<services>       <service name="WcfServiceNetMSMQ.Service1" behaviorConfiguration="WcfServiceNetMSMQ.Service1Behavior">         <host>           <baseAddresses>             <add baseAddress = "http://localhost:8010/WcfServiceNetMSMQ/Service1/" />           </baseAddresses>         </host>         <endpoint address ="net.msmq://localhost/private/myqueue" binding="netMsmqBinding" contract="WcfServiceNetMSMQ.IService1">           <identity>             <dns value="localhost"/>           </identity>         </endpoint>         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>       </service>     </services> 
like image 457
Neo Avatar asked Jun 23 '11 12:06

Neo


People also ask

What is Servicebehaviors in WCF?

Behavior types are added to the service or service endpoint description objects (on the service or client, respectively) before those objects are used by Windows Communication Foundation (WCF) to create a runtime that executes a WCF service or a WCF client.

Which behavior controls how many messages are processed?

Service Behavior: Throttling exposes properties that you can control how many instances or sessions are created at the application level.


Video Answer


1 Answers

There are 3 important sections when you configure a WCF service.

1) Defining the Services:

<services>       <service behaviorConfiguration="SOAPRESTDemoBehavior" name="SOAPRESTDemo">         <endpoint address="rest" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" binding="webHttpBinding" contract="ISOAPRESTDemo" />         <endpoint address="soap" binding="basicHttpBinding" contract="ISOAPRESTDemo" />       </service>     </services> 

NOTE the value of behaviorConfiguration is a reference to a section further on in the config see below...

2) Defining the 'Service Behaviours'

 <serviceBehaviors>         <behavior name="SOAPRESTDemoBehavior">           <serviceMetadata httpGetEnabled="true"/>           <serviceDebug includeExceptionDetailInFaults="true"/>         </behavior>       </serviceBehaviors> 

3) Defining the 'Endpoint Behaviours'

<endpointBehaviors>         <behavior name="SOAPRESTDemoEndpointBehavior">           <webHttp/>         </behavior>       </endpointBehaviors> 

All 3 sections are the basics for what you need to set up a service (although this can be done programatically).

With regard to your question the behaviorConfiguration section relates to point 2 and 3 in my points above. Its where you lay out the sort of actions you want your service to have. for example above I have said that I want to allow MetaData to be published. This will essentially create a WSDL which describes the service.

The full config is here:

<?xml version="1.0"?> <configuration>      <system.web>         <compilation debug="true" targetFramework="4.0" />     </system.web>    <system.serviceModel>      <!--Set up the service-->     <services>       <service behaviorConfiguration="SOAPRESTDemoBehavior" name="SOAPRESTDemo">         <endpoint address="rest" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" binding="webHttpBinding" contract="ISOAPRESTDemo" />         <endpoint address="soap" binding="basicHttpBinding" contract="ISOAPRESTDemo" />       </service>     </services>       <!--Define the behaviours-->     <behaviors>        <serviceBehaviors>         <behavior name="SOAPRESTDemoBehavior">           <serviceMetadata httpGetEnabled="true"/>           <serviceDebug includeExceptionDetailInFaults="true"/>         </behavior>       </serviceBehaviors>        <endpointBehaviors>         <behavior name="SOAPRESTDemoEndpointBehavior">           <webHttp/>         </behavior>       </endpointBehaviors>      </behaviors>    </system.serviceModel>  </configuration> 
like image 114
Exitos Avatar answered Sep 19 '22 06:09

Exitos