WCF不能仅在PROD环境中创建自定义端点行为



我有一个WCF rest web服务。在我的开发环境中一切都很好(#developmentusingIISExpress),但在我的生产环境中出现了以下错误:

"/Services"应用程序中的服务器错误。--------------------------------------------------------------------------------

Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'inspectMessageBehavior' cannot be added to this element.  Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions.
Parameter name: element
Source Error: 

Line 16:            </service>
Line 17:        </services>
Line 18:        <behaviors>
Line 19:            <endpointBehaviors>
Line 20:                <behavior name="webHttp">

Source File: C:OtimisAdvLinkForWebServiceservicesweb.config    Line: 18 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 

这是我的web.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="AdvLinkForWebService.inbound">
                <endpoint address=""
                          binding="webHttpBinding"
                          contract="AdvLinkForWebService.Iinbound"
                          behaviorConfiguration="defaultWebHttpBehavior"/>
            </service>
            <service name="AdvLinkForWebService.config">
                <endpoint address=""
                          binding="webHttpBinding"
                          contract="AdvLinkForWebService.Iconfig"
                          behaviorConfiguration="webHttp"/>
            </service>
        </services>
        <behaviors>
            <endpointBehaviors>
                <behavior name="webHttp">
                    <webHttp/>
                </behavior>
                <behavior name="defaultWebHttpBehavior">
                    <inspectMessageBehavior/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <extensions>
            <behaviorExtensions>
                <add name="inspectMessageBehavior"
                     type="AdvLinkForWebService.MessageInspector.InspectMessageBehaviorExtension, AdvLinkForWebService"/>
            </behaviorExtensions>
        </extensions>
    </system.serviceModel>
</configuration>

这个问题与这个有关

要在生产环境中正常运行,必须指定inspectMessageBehavior的版本、区域性和密钥。最终得到以下配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <extensions>
            <behaviorExtensions>
                <add name="inspectMessageBehavior"
                     type="AdvLinkForWebService.MessageInspector.InspectMessageBehaviorExtension, AdvLinkForWebService, Version=1.0.5791.17758, Culture=neutral, PublicKeyToken=null"/>
            </behaviorExtensions>
        </extensions>
        <behaviors>
            <endpointBehaviors>
                <behavior name="defaultWebHttpBehavior">
                    <webHttp/>
                    <inspectMessageBehavior/>
                </behavior>
                <behavior name="webHttp">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <services>
            <service name="AdvLinkForWebService.inbound">
                <endpoint address=""
                          binding="webHttpBinding"
                          contract="AdvLinkForWebService.Iinbound"
                          behaviorConfiguration="defaultWebHttpBehavior"/>
            </service>
            <service name="AdvLinkForWebService.config">
                <endpoint address=""
                          binding="webHttpBinding"
                          contract="AdvLinkForWebService.Iconfig"
                          behaviorConfiguration="webHttp"/>
            </service>
        </services>
    </system.serviceModel>
</configuration>

我不知道版本号是如何生成的,即使它可以控制,但我通过以下命令获得了它:

typeof(InspectMessageBehaviorExtension).AssemblyQualifiedName

相关内容

  • 没有找到相关文章

最新更新