2
votes

I need to pass more than 64kb of data through the WCF service. To do that I've configured server side (that hosts WCF service) in the following way:

<services>
  <service name="MyService" behaviorConfiguration="MyServiceBehavior" >
    <endpoint address="" binding="customBinding" contract="MyContract"
      bindingName="testBinding" bindingConfiguration="testBinding" />
    <endpoint address="mex" binding="customBinding" contract="IMetadataExchange"
      bindingName="testBinding" bindingConfiguration="testBinding" />
  </service>
</services>

<bindings>
  <customBinding>
    <binding name="testBinding" >
      <textMessageEncoding>
        <readerQuotas maxDepth="2147483647"
          maxStringContentLength="2147483647"
          maxArrayLength="2147483647"
          maxBytesPerRead="2147483647"
          maxNameTableCharCount="2147483647" />
      </textMessageEncoding>
      <httpTransport transferMode="Buffered"
        maxReceivedMessageSize="2147483647"
        maxBufferSize="2147483647"/>
    </binding>
  </customBinding>
</bindings>

And client side (that consumes service):

<client>
  <endpoint address="http://localhost:82/MyService.svc"
    binding="customBinding" bindingConfiguration="testBinding"
    contract="MyContract"
    name="MyName" />
</client>

<bindings>
  <customBinding>
    <binding name="testBinding" >
      <textMessageEncoding>
        <readerQuotas maxDepth="2147483647"
          maxStringContentLength="2147483647"
          maxArrayLength="2147483647"
          maxBytesPerRead="2147483647"
          maxNameTableCharCount="2147483647" />
      </textMessageEncoding>
      <httpTransport transferMode="Buffered"
        maxReceivedMessageSize="2147483647"
        maxBufferSize="2147483647"/>
    </binding>
  </customBinding>
</bindings>

When I called required method I've received the following error:

Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:82/MyService.svc. The client and service bindings may be mismatched.

Please advice, what is mismatch in my bindings?

Thanks.

2

2 Answers

2
votes

Seems like your doing a few steps too many - too complicated. Why don't you just use a binding configuration based on an existing binding?? Something like this:

<bindings>
  <basicHttpBinding>
    <binding name="largeBinding"
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas
          maxArrayLength="2147483647" maxBytesPerRead="2147483647"
          maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="MyService" behaviorConfiguration="MyServiceBehavior" >
    <endpoint 
        address="" 
        binding="basicHttpBinding" 
        bindingConfiguration="largeBinding"
        contract="MyContract" />
    <endpoint 
        address="mex" 
        binding="mexHttpBinding" 
        contract="IMetadataExchange" />
  </service>
</services>

Define the exact same binding configuration on the client side and use it there, too.

Also, your MEX endpoint for metadata exchange should NEVER have any special setup - just use the default mexHttpBinding and don't configure any binding configuration for that.

0
votes

Make sure that the service name in the server configuration file matches the fully-qualified name of the service - the name attribute in the <system.serviceModel/services/service> element. If it doesn't match, then WCF will provide a default endpoint whose binding is basicHttpBinding (and the content-type it expects is different than the one the client is sending).