无法激活服务器上的二进制 http 绑定

发布于 2024-11-07 09:09:02 字数 2173 浏览 0 评论 0原文

我正在尝试按照本网站上的许多示例在 WCF 服务中使用二进制消息编码。

在服务器上,我将绑定声明如下:

<customBinding>
    <binding name="binaryHttpBinding">
        <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000">
            <readerQuotas maxDepth="32" maxStringContentLength="4096000"
            maxArrayLength="4096000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binaryMessageEncoding>
        <httpTransport maxBufferPoolSize="4096000" maxBufferSize="4096000" maxReceivedMessageSize="4096000"/>
    </binding>
</customBinding>

服务设置为使用它(我认为):

<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">
    <endpoint
        address=""
        binding="customBinding"
        bindingConfiguration="binaryHttpBinding"
        contract="MyService.IContentUpload"
        name="MyService.ContentUploadService"  />

客户端具有相同的声明:

<customBinding>
    <binding name="binaryHttpBinding">
        <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000">
            <readerQuotas maxDepth="32" maxStringContentLength="4096000"
            maxArrayLength="4096000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binaryMessageEncoding>
        <httpTransport maxBufferPoolSize="4096000" maxBufferSize="4096000" maxReceivedMessageSize="4096000"/>
    </binding>
</customBinding>

并且:

<endpoint
    address="http://foo.com/ContentUploadService.svc"
    binding="customBinding"
    bindingConfiguration="binaryHttpBinding"
    contract="MyService.IContentUpload"
    name="MyService.ContentUploadService"/>

客户端似乎正在工作,但服务器抛出一个异常,表明绑定未到位:

内容类型 application/soap+msbin1 被发送到期望的服务 文本/xml;字符集=utf-8。客户 和服务绑定可能是 不匹配。

日志文件中紧接此错误之前的是尝试打开服务主机时抛出的错误,这一定是原因。

配置评估上下文不 找到了。

我为此消息尝试过的搜索链接都没有帮助。那么,我缺少什么基本部分?

I'm trying to use binary message encoding in a WCF service, following the many examples on this site.

On the server I have the binding declared as so:

<customBinding>
    <binding name="binaryHttpBinding">
        <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000">
            <readerQuotas maxDepth="32" maxStringContentLength="4096000"
            maxArrayLength="4096000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binaryMessageEncoding>
        <httpTransport maxBufferPoolSize="4096000" maxBufferSize="4096000" maxReceivedMessageSize="4096000"/>
    </binding>
</customBinding>

The service is set to use it (I think):

<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">
    <endpoint
        address=""
        binding="customBinding"
        bindingConfiguration="binaryHttpBinding"
        contract="MyService.IContentUpload"
        name="MyService.ContentUploadService"  />

The client has the same declarations:

<customBinding>
    <binding name="binaryHttpBinding">
        <binaryMessageEncoding maxReadPoolSize="4096000" maxSessionSize="4096000" maxWritePoolSize="4096000">
            <readerQuotas maxDepth="32" maxStringContentLength="4096000"
            maxArrayLength="4096000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binaryMessageEncoding>
        <httpTransport maxBufferPoolSize="4096000" maxBufferSize="4096000" maxReceivedMessageSize="4096000"/>
    </binding>
</customBinding>

And:

<endpoint
    address="http://foo.com/ContentUploadService.svc"
    binding="customBinding"
    bindingConfiguration="binaryHttpBinding"
    contract="MyService.IContentUpload"
    name="MyService.ContentUploadService"/>

The client appears to be working, but the server throws an exception that indicates that the binding is not in place:

Content Type application/soap+msbin1
was sent to a service expecting
text/xml; charset=utf-8. The client
and service bindings may be
mismatched.

Immediately prior to this error in the log file is this one, thrown when trying to open the service host, which must be the cause.

Configuration evaluation context not
found.

None of the search links I've tried for this message have been helpful. So, what basic piece am I missing?

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

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

发布评论

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

评论(2

给妤﹃绝世温柔 2024-11-14 09:09:02

您是否尝试过在服务器上设置主机来补充端点?

我认为这会是这样的:

<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">    
<host>
   <baseAddresses>
      <add baseAddress="http://foo.com/ContentUploadService.svc"/>
   </baseAddresses>
</host>
<endpoint address="" binding="customBinding" indingConfiguration="binaryHttpBinding" contract="MyService.IContentUpload" name="MyService.ContentUploadService" />

希望这有帮助

Have you tried setting up a host on the server to compliment the endpoint?

I think it would be something like this:

<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">    
<host>
   <baseAddresses>
      <add baseAddress="http://foo.com/ContentUploadService.svc"/>
   </baseAddresses>
</host>
<endpoint address="" binding="customBinding" indingConfiguration="binaryHttpBinding" contract="MyService.IContentUpload" name="MyService.ContentUploadService" />

Hope this is helpful

峩卟喜欢 2024-11-14 09:09:02

在我看来,您的服务正在使用默认配置,如果找不到显式配置,就会发生这种情况。确保元素的名称属性与服务类的完全限定名称(包括命名空间)完全匹配。

It looks to me like your service is using the default configuration, which would happen if it cannot find an explicit configuration. Make sure the name attribute of the element exactly matches the fully qualified name of your service class (namespace included).

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