2011-06-23 24 views
20

¿cuál es el atributo de servicio "behaviorConfiguration"?¿qué es el atributo de servicio "behaviorConfiguration"?

<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> 

Respuesta

26

es una referencia a otra sección de configuración:

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

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

Cuando esta sección contiene una cierta configuración global para todo el servicio.

4

he aquí un ejemplo de ello, lleva algunas propiedades de la conexión del servicio.

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

en cuenta que la name en este comportamiento del servicio corresponde a la especificada anteriormente.

Espero que ayude.

42

Hay 3 secciones importantes cuando configura un servicio WCF.

1) Definición de los Servicios:

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

NOTA el valor de behaviorConfiguration es una referencia a una sección más adelante en la configuración véase más adelante ...

2) La definición de los 'comportamientos de servicio'

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

3) Definición de la 'Punto de llegada Comportamientos'

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

Las 3 secciones son los elementos básicos de lo que necesita para configurar un servicio (aunque esto se puede hacer mediante programación).

Con respecto a su pregunta, la sección de Conformidad del comportamiento se relaciona con el punto 2 y 3 en mis puntos anteriores. Es donde se establece el tipo de acciones que desea que tenga su servicio. por ejemplo, arriba he dicho que quiero permitir que se publique MetaData. Esto esencialmente creará un WSDL que describa el servicio.

La configuración completa está aquí:

<?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> 
0

Usted recibirá este error con el nombre comportamiento no se ha configurado correctamente.

El documento HTML no contiene información de descubrimiento del servicio web. Los metadatos contienen una referencia que no se puede resolver: 'http://blabla.com/WebService/Processor.svc'. Tipo de contenido application/soap + xml; charset = utf-8 no era compatible con el servicio 'http://blabla.com/WebService/Processor.svc'. Los enlaces de cliente y servicio pueden no coincidir. El servidor remoto devolvió un error: (415) No se puede procesar el mensaje porque el tipo de contenido 'application/soap + xml; charset = utf-8 'no era el tipo esperado' text/xml; charset = utf-8 '.. Si el servicio está definido en la solución actual, intente construir la solución y agregar nuevamente la referencia de servicio.

Cuestiones relacionadas