I have just a very basic WCF service implemented and I want the clients to have some properties in their config automatically generated, like maxReceivedMessageSize, maxBufferSize, etc (the default maxReceivedMessageSize is not enough for me). I have the below config in service application's web.config file. I have the properly configured binding (BasicHttpBinding_IService1_YY), that binding is referenced in both service endpoint and client endpoint (I am not sure there is need for client endpoint as well). I also have mexHttpBinding typed endpoint under service. The service points to a behaviour where httpGetEnabled is true. After all, when I generate the client from this the binding parameters won't be there, it will use the default values. Naturally the wsdl doesn't contain those parameters.
So my question would be is this something that is out of WCF's scope? Do I have to manually maintenance the client config from this perspective if something change? Is there any solution for this issue, because I went through many stackoverflow and other topics and found nothing or I was careless.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" policyVersion="Policy15" httpGetBindingConfiguration="BasicHttpBinding_IService1_YY" />
<!-- 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>
<services>
<service name="WcfServiceApplication.Service1" behaviorConfiguration="myServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:51483/"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="WcfServiceApplication.IService1"
bindingConfiguration="BasicHttpBinding_IService1_YY" name="BasicHttpBinding_IService1_YY" >
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" >
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1_YY"
maxReceivedMessageSize="20000099" maxBufferSize="20000099" maxBufferPoolSize="20000099"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1_YY" contract="WcfServiceApplication.IService1"
name="BasicHttpBinding_IService1_YY" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
And the generated client config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1_YY" sendTimeout="00:05:00" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51483/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1_YY" contract="IService1"
name="BasicHttpBinding_IService1_YY" />
</client>
</system.serviceModel>
</configuration>
Ok, the name of the binding really appears correctly, but nothing more. When I manually adjust it, then everything works ok, but I think there should be a more suitable solution.
Can you please help me out at this one? Thanks in advance.
CodePudding user response:
The answer is probably: Yes.
The feature of WCF is that the client and server can evolve separately. The server settings are not automatically updated to the client, you need to manually set the parameters you need on the client.
You may try using the "update service reference" feature to update instead of creating a new service reference.