Frank im Wald
Frank im Wald

Reputation: 918

WCF: strange automatic service reference

I created a simple WCF service with netHttp binding, and then automatically added service references from it into another application via "Add service reference|Discover". The resulting binding looks weird.

Instead of the original NetHttpBinding I get a CustomBinding.

It works, but annoyingly I can't add a maxReceivedMessageSize to a custom binding.

Question: Is there any good reason for this, or can I safely replace the custom binding with the original netHttpBinding?

The host's app.config:

  <endpoint address="images/netbh" binding="netHttpBinding" contract="WcfImageService.IImageService" bindingConfiguration="netHttp_bh" />

  <netHttpBinding>
    <binding name="netHttp_bh" messageEncoding="Binary">
      <webSocketSettings transportUsage="Never"/>
    </binding>
  </netHttpBinding>

The client's generated app.config:

        <customBinding>
            <binding name="NetHttpBinding_IImageService1" >
                <binaryMessageEncoding />
                <httpTransport />
            </binding>
        </customBinding>

        <endpoint address="http://localhost:8080/images/netbh" binding="customBinding"
            bindingConfiguration="NetHttpBinding_IImageService1" contract="ImageServiceReference.IImageService"
            name="NetHttpBinding_IImageService1" />

I'm using Visual Studio 2015, in case that matters.

Upvotes: 0

Views: 102

Answers (1)

Marc Selis
Marc Selis

Reputation: 833

I don't know why you get a customBinding in the client (I think the wsdl.exe tool that Visual Studio uses behind the scenes is a bit confused) but you can safely replace the custom binding with the original webHttpBinding.

As an alternative, I think you can also specify can also specify maxReceivedMessageSize on the <httpTransport> element like this:

<httpTransport maxReceivedMessageSize="2000000000" />

Upvotes: 1

Related Questions