WCF - 二进制编码通过HTTP扔客户端和服务绑定不匹配异常 [英] WCF - Binary Encoding over HTTP throwing client and service binding mismatch exception

查看:202
本文介绍了WCF - 二进制编码通过HTTP扔客户端和服务绑定不匹配异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例外:




内容类型的应用/肥皂+ msbin1
不是由服务
支持<一个HREF =HTTP://本地主机:1500 / MyService.svc> HTTP://本地主机:1500 / MyService.svc 。
中的客户端和服务绑定可能是
不匹配




客户端配置:

 < system.serviceModel> 
<&绑定GT;

< customBinding>
<绑定名称=NetHttpBindingcloseTimeout =00:01:00
openTimeout =00:01:00receiveTimeout =00:10:00的SendTimeout =00:01: 00>
< binaryMessageEncoding />
< httpTransport allowCookies =假bypassProxyOnLocal =false的
hostNameComparisonMode =StrongWildcardMAXBUFFERSIZE =65536
maxBufferPoolSize =524288maxReceivedMessageSize =65536
transferMode =缓冲useDefaultWebProxy =真/>
< /&结合GT;
< / customBinding>

< /绑定>
<客户端>
<端点地址=HTTP://本地主机:1500 / MyService.svc
结合=customBindingbindingConfiguration =NetHttpBinding
合同=APP.BLL.IMyServiceContract的名字=MyServiceEndpoint/>
< /客户>
< /system.serviceModel>



服务器配置:

 < system.serviceModel> 
<&绑定GT;
< customBinding>
<绑定名称=NetHttpBindingcloseTimeout =0点01分00秒
openTimeout =0点01分00秒receiveTimeout =0点10分○○秒的SendTimeout =0时01分: 00>
< binaryMessageEncoding />
< httpTransport allowCookies =假bypassProxyOnLocal =false的
hostNameComparisonMode =StrongWildcardMAXBUFFERSIZE =65536
maxBufferPoolSize =524288maxReceivedMessageSize =65536
transferMode =缓冲useDefaultWebProxy =真/>
< /&结合GT;
< / customBinding>
< /绑定>

<服务和GT;
<服务名称=MyAppService>
<端点地址=绑定=customBindingbindingConfiguration =NetHttpBinding
合同=APP.BLL.IMyServiceContract>
< /端点>
< /服务>
< /服务>

<&行为GT;
< serviceBehaviors>
<&行为GT;
<! - 为了避免泄露的元数据信息,下面设置为false的价值和部署之前删除上面的元数据终结点 - >
< serviceMetadata httpGetEnabled =真/>
<! - 要接收的异常细节的故障进行调试,下面设置为true值。设置为false部署之前,以避免泄露异常信息 - >
< serviceDebug includeExceptionDetailInFaults =真/>
< /行为>
< / serviceBehaviors>
< /行为>

< serviceHostingEnvironment multipleSiteBindingsEnabled =真/>

< /system.serviceModel>


解决方案

您不能使用 binaryMessageEncoding HTTP customBindings 。您可以使用 textMessageEncoding mtomMessageEncoding 开箱即用。



请参阅此博客张贴的使用的 customBindings 与。HTTP传输



<预类=郎咸平的XML prettyprint-覆盖> <&绑定GT;
< customBinding>
<绑定名称=basicHttpBinaryBinding>
< binaryMessageEncoding />
< httpTransport />
< /&结合GT;
< / customBinding>
< /绑定>


The exception:

Content Type application/soap+msbin1 was not supported by service http://localhost:1500/MyService.svc. The client and service bindings may be mismatched.

The client configuration:

  <system.serviceModel>
    <bindings>

    <customBinding>
        <binding name="NetHttpBinding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
          <binaryMessageEncoding />
          <httpTransport allowCookies="false" bypassProxyOnLocal="false"
                         hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
                         maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                         transferMode="Buffered" useDefaultWebProxy="true" />
        </binding>
      </customBinding>

    </bindings>
    <client>
      <endpoint address="http://localhost:1500/MyService.svc"
        binding="customBinding" bindingConfiguration="NetHttpBinding"
        contract="APP.BLL.IMyServiceContract" name="MyServiceEndpoint" />
    </client>
  </system.serviceModel>

The server configuration:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="NetHttpBinding" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
          <binaryMessageEncoding />
          <httpTransport allowCookies="false" bypassProxyOnLocal="false"
                         hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
                         maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                         transferMode="Buffered" useDefaultWebProxy="true" />
        </binding>
      </customBinding>
    </bindings>

    <services>
      <service name="MyAppService">
        <endpoint address="" binding="customBinding" bindingConfiguration="NetHttpBinding"
                  contract="APP.BLL.IMyServiceContract">
        </endpoint>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

  </system.serviceModel>

解决方案

You cannot use binaryMessageEncoding and HTTP without customBindings. You can use textMessageEncoding or mtomMessageEncoding out of the box.

See this blog post for reference on using customBindings with HTTP transport.

<bindings>
    <customBinding>
      <binding name="basicHttpBinaryBinding">
        <binaryMessageEncoding />             
        <httpTransport />
      </binding>
    </customBinding>
</bindings>

这篇关于WCF - 二进制编码通过HTTP扔客户端和服务绑定不匹配异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆