开发者

WCF - Binary Encoding over HTTP throwing client and service binding mismatch exception

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="St开发者_运维百科rongWildcard" 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜