什么是服务的"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>
Run Code Online (Sandbox Code Playgroud)
Exi*_*tos 47
配置WCF服务时有3个重要部分.
1)定义服务:
<services>
<service behaviorConfiguration="SOAPRESTDemoBehavior" name="SOAPRESTDemo">
<endpoint address="rest" behaviorConfiguration="SOAPRESTDemoEndpointBehavior" binding="webHttpBinding" contract="ISOAPRESTDemo" />
<endpoint address="soap" binding="basicHttpBinding" contract="ISOAPRESTDemo" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
注意,behaviorConfiguration的值是对配置中进一步部分的引用,见下文...
2)定义"服务行为"
<serviceBehaviors>
<behavior name="SOAPRESTDemoBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
Run Code Online (Sandbox Code Playgroud)
3)定义"端点行为"
<endpointBehaviors>
<behavior name="SOAPRESTDemoEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
Run Code Online (Sandbox Code Playgroud)
所有3个部分都是您设置服务所需的基础(虽然这可以以编程方式完成).
关于你的问题,behaviorConfiguration部分与我上面的观点中的第2点和第3点有关.它是您布置您希望服务具有的行为的地方.例如上面我说过我想允许MetaData发布.这实际上将创建一个描述服务的WSDL.
完整配置在这里:
<?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>
Run Code Online (Sandbox Code Playgroud)
Lad*_*nka 28
它是对另一个配置部分的引用:
<behaviors>
<serviceBehaviors>
<behavior name="WcfServiceNetMSMQ.Service1Behavior">
</behaviors>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
此部分包含整个服务的一些全局配置.
| 归档时间: |
|
| 查看次数: |
50925 次 |
| 最近记录: |