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

Dav*_*vid 8 .net c# wcf wcf-binding

我正在尝试在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>
Run Code Online (Sandbox Code Playgroud)

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

<service behaviorConfiguration="MyService.ServiceBehavior" name="MyService.ContentUploadService">
    <endpoint
        address=""
        binding="customBinding"
        bindingConfiguration="binaryHttpBinding"
        contract="MyService.IContentUpload"
        name="MyService.ContentUploadService"  />
Run Code Online (Sandbox Code Playgroud)

客户端具有相同的声明:

<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>
Run Code Online (Sandbox Code Playgroud)

和:

<endpoint
    address="http://foo.com/ContentUploadService.svc"
    binding="customBinding"
    bindingConfiguration="binaryHttpBinding"
    contract="MyService.IContentUpload"
    name="MyService.ContentUploadService"/>
Run Code Online (Sandbox Code Playgroud)

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

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

在日志文件中出现此错误之前,就会在尝试打开服务主机时抛出此错误,这必须是原因.

找不到配置评估上下文.

我为此消息尝试的搜索链接都没有帮助.那么,我错过了什么基本文章?

Bri*_*haw 1

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

我认为它会是这样的:

<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" />
Run Code Online (Sandbox Code Playgroud)

希望这有帮助