[ACCEPTED]-what is the "behaviorConfiguration" attribute of service?-wcf

Accepted answer
Score: 50

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

1) Defining the 15 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 14 is a reference to a section further on in 13 the config see below...

2) Defining the 'Service 12 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 11 3 sections are the basics for what you need 10 to set up a service (although this can be 9 done programatically).

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

The 1 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>
Score: 30

It is a reference to another configuration 2 section:

<behaviors>
   <serviceBehaviors>
      <behavior name="WcfServiceNetMSMQ.Service1Behavior">

      </behaviors>
   </serviceBehaviors>
</behaviors>

Where this section contains some 1 global configuration for the whole service.

Score: 4

here's an example of it, it carries some 4 properties of the connection of the service.

<serviceBehaviors>
<behavior name="WcfServiceNetMSMQ.Service1Behavior">
 <serviceMetadata httpGetEnabled="true" />
 <serviceDebug includeExceptionDetailInFaults="false" />
</behavior>

Notice 3 that the name in this service behavior corresponds 2 to the one you specified earlier.

Hope that 1 helps.

Score: 0

You will get this error with Behavior name 13 is not setup correctly.

The HTML document 12 does not contain Web service discovery information. Metadata 11 contains a reference that cannot be resolved: 'http://blabla.com/WebService/Processor.svc'. Content 10 Type application/soap+xml; charset=utf-8 9 was not supported by service 'http://blabla.com/WebService/Processor.svc'. The client 8 and service bindings may be mismatched. The 7 remote server returned an error: (415) Cannot 6 process the message because the content 5 type 'application/soap+xml; charset=utf-8' was 4 not the expected type 'text/xml; charset=utf-8'.. If 3 the service is defined in the current solution, try 2 building the solution and adding the service 1 reference again.

More Related questions