0

How can I change the web.config to define the maxReceivedMessageSize for https in my WCF webservice?

I have a WCF 4 web service operating across HTTPS and I want to set the maxReceivedMessageSize for the binding.

The web config has a protocol mapping:

<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>

I have tried removing the mapping and using an endpoint:

<services>
      <service name="Company.Product.Service">
      <host>
          <baseAddresses>
            <add baseAddress="https://mydomain/dir" />
          </baseAddresses>
      </host>
        <endpoint address="Service.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="IService">
        </endpoint>
      </service>
</services>

...

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService" 
           maxBufferPoolSize="2147483647" 
           maxBufferSize="2147483647" 
           maxReceivedMessageSize="2147483647" 
           messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None" />
            </security>
        </binding>
      </basicHttpBinding>

But when I remove the protocol mapping, I get:

Service cannot be started. System.InvalidOperationException: Service 'MyServiceNamespace.RequestProcessorImpl' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

How can I change the configuration to define the maxReceivedMessageSize for https in my WCF webservice?

Jayden
  • 2,656
  • 2
  • 26
  • 31

1 Answers1

1

Thanks to Tim for his post which led me to an answer.

The key for me was to omit the 'name' attribute in a binding defined as <basicHttpsBinding>:

<basicHttpsBinding>
        <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None" />
                <message clientCredentialType="Certificate" algorithmSuite="Default" />
            </security>
        </binding>

This then overrides the defaul pointed to by the protocol mapping.

Community
  • 1
  • 1
Jayden
  • 2,656
  • 2
  • 26
  • 31