自定义绑定元素无法在 IIS 下的 WCF 中加载,但可以在 WCF 自托管下加载

发布于 2024-11-06 07:40:35 字数 784 浏览 1 评论 0原文

我能够运行 MSFT WCF 示例下载附带的 WCF-SecureProfile 示例 (http://msdn.microsoft.com/en-us/library/ee818238.aspx

但是我无法将此服务器组件移植到 IIS。我得到的错误是 无法加载 。考虑到我已加载行为扩展,我不知道为什么 IIS 无法看到该扩展,但我的应用程序的自托管版本可以。在此处输入图像描述

我将项目的源代码上传到 codeplex 以便于浏览。这是指向 web.config 和所有其他文件的直接链接。

在此处输入图像描述2

I'm able to run the WCF-SecureProfile sample that comes with the MSFT WCF samples download (http://msdn.microsoft.com/en-us/library/ee818238.aspx)

However I can't port this server component to IIS. I get the error that
<MakeConnectionBindingElement/> can't be loaded. Considering that I have the behavior extensions loaded I don't know why IIS can't see the extension, however the self-host version of my app can.enter image description here

I uploaded the sourcecode of the project into codeplex for easy browsing. Here is a direct link to web.config and all other files.

enter image description here2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-11-13 07:40:35

我获取了示例并将其设置为在本地 IIS 上运行。我没有遇到与这个问题相同的问题,但我确实遇到了一个大问题。访问 IIS 中的服务时出现以下错误消息:

合约需要 Duplex,但绑定“BasicHttpBinding”不支持它或未正确配置以支持它。

经过一番绞尽脑汁,我找到了这个问题的原因。 WCF 4 现在为每个传输分配默认绑定(我越来越喜欢这个功能)。对于 HTTP 传输,默认绑定是 basicHttpBinding。问题是 customBinding 配置不会覆盖任何默认绑定。这会导致 WCF 尝试通过 basicHttpBinding 配置双工,这当然不受支持。修复方法是关闭 HTTP 的默认传输映射,并将其分配给您的自定义绑定,如下所示:

    <protocolMapping>
        <clear/> <!-- removes all defaults which you may or may not want. -->
        <!-- If not, use <remove scheme="http" /> -->
        <add scheme="http" binding="customBinding" bindingConfiguration="rspBinding"/>
    </protocolMapping>

将其添加到 serviceModel 元素后,基于 IIS 的服务工作得很好。

I got the sample and set it up to run on IIS local. I didn't get the same issue as the one in this question but I did run into a big gotcha. Accessing the service in IIS gave me this error message:

Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.

After some head scratching, I found the cause of this issue. WCF 4 now assigns default bindings to each transport (I'm liking this feature less & less). For the HTTP transport, the default binding is basicHttpBinding. The problem is the customBinding config does not override any default binding. This causes WCF to attempt to configure duplex over basicHttpBinding which of course isn't supported. The fix is to turn off the default transport mapping for HTTP and assign it to your custom binding as shown below for this service:

    <protocolMapping>
        <clear/> <!-- removes all defaults which you may or may not want. -->
        <!-- If not, use <remove scheme="http" /> -->
        <add scheme="http" binding="customBinding" bindingConfiguration="rspBinding"/>
    </protocolMapping>

Once I added this to the serviceModel element, the IIS based service worked just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文