How to? WCF customBinding over Https
- by user663414
Hi all,
I'm trying to setup a WCF service for internal use, on our external facing web-farm (we dont have a web farm internally, and I need this service to have failover and load-balancing).
Requirements:
PerSession state, as we need the service to retain variable data for each session.
HTTPS. After lots of googling i've read I needed to create a customBinding, which I've done, but not sure if it is correct.
Larger message size, as one of the parameters is a byte[] array, which can be a max of 5mb.
no requirement to manually edit the client-side app.config. ie, I need the Developer to just add the service reference, and then starts using the object without fiddly changing of app.config.
Note: I've previously had this service working under HTTP correctly (using wsHttpBinding).
I've also had it working under HTTPS, but it didn't support PerSession state, and lost internal variable values each function call.
I'm currently getting this error from the test harness:
Could not find default endpoint element that references contract 'AppMonitor.IAppMonitorWcfService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
NOTE: The error is arising on an Test Harness EXE, that has the WCF service referenced directly under Service References. This is not the problem of an exe referencing another object, that then references the WCF service, that i've read about.
The WSDL is showing correctly when browsing to the URL.
Web.Config:
<system.serviceModel>
<services>
<service name="AppMonitor.AppMonitorWcfService" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="customBinding" bindingConfiguration="EnablePerSessionUnderHttps" contract="AppMonitor.IAppMonitorWcfService"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<customBinding>
<binding name="EnablePerSessionUnderHttps" maxReceivedMessageSize="5242880">
<reliableSession ordered="true"/>
<textMessageEncoding>
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpsTransport authenticationScheme="Anonymous" requireClientCertificate="false"/>
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
EXE's App.config (auto-generated when adding the Service Reference):
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CustomBinding_IAppMonitorWcfService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client />
</system.serviceModel>
</configuration>
I'm not sure why the app.config is showing wsHttpBinding? Shouldn't this be customBinding?
I really dont want to have to edit the app.config, as this service will be used by dozens of developers, and I want them to just be able to add the Service Reference, and away they go...
Using VS2008, .NET 3.51.
I think server is IIS7, Win Server 2008, can confirm if needed.