Hi,
I have application connected to 2 databases by 2 services (1) and I must to redirect this to server 0 like at (2):

When I stariting app I have combobox to select server: Prod or Test.
- public enum Access
- {
- Test,
- ProdL,
- }
- private static Access _serviceAccess = Access.Prod;
- private static ServiceClient service;
- private static void SetServiceAccess(Access access)
- {
- switch (_serviceAccess )
- {
- case Access .Prod: service= new ServiceClient("WSHttpBinding_IService.Prod");
- break;
- case Access .Test: service = new ServiceClient("WSHttpBinding_IService.Test");
- break;
- }
- }
- --app.config
- xml version="1.0" encoding="utf-8" ?>
- <configuration>
- <system.web>
- <compilation debug="true"/>
- system.web>
- <system.serviceModel>
- <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
- <bindings>
- <wsHttpBinding>
- <binding name="WSHttpBinding_IService.Prod"
- closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00"
- sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false"
- hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="52042880"
- maxReceivedMessageSize="2147483647" messageEncoding="Mtom" textEncoding="utf-8"
- useDefaultWebProxy="true" allowCookies="false">
- <readerQuotas maxDepth="62" maxStringContentLength="80000192"
- maxArrayLength="666116384" maxBytesPerRead="40000096" maxNameTableCharCount="160000384" />
- <reliableSession ordered="true" inactivityTimeout="00:10:00"
- enabled="false" />
- <security mode="None" />
- binding>
- <binding name="WSHttpBinding_IService.Test" closeTimeout="00:03:00"
- openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
- bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
- maxBufferPoolSize="52042880" maxReceivedMessageSize="2147483647"
- messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
- allowCookies="false">
- <readerQuotas maxDepth="62" maxStringContentLength="80000192"
- maxArrayLength="666116384" maxBytesPerRead="40000096" maxNameTableCharCount="160000384" />
- <reliableSession ordered="true" inactivityTimeout="00:10:00"
- enabled="false" />
- <security mode="None" />
- binding>
- wsHttpBinding>
- bindings>
- <client>
- <endpoint address="http://ProdAddress/Service.svc"
- binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService.Prod"
- contract="Service.IService" name="WSHttpBinding_IService.Prod">
- <identity>
- <dns value="localhost" />
- identity>
- endpoint>
- <endpoint address="http://TestAddress/Service.svc"
- binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService.Test"
- contract="Service.IService" name="WSHttpBinding_IService.Test">
- <identity>
- <dns value="localhost" />
- identity>
- endpoint>
- client>
- system.serviceModel>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
- startup>
- configuration>
- -- web.config 1 and web.config 2 (the same configuration but different connection strings)
- xml version="1.0"?>
- <configuration>
- <appSettings>
- <add key="DbConnStr" .../>
- <add key="ManagementConnStr" ... />
- appSettings>
- <system.serviceModel>
- <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
- <services>
- <service name="ServiceName" behaviorConfiguration="ServiceBehaviour">
- <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding" contract="Service.IService">
- <identity>
- <dns value="localhost"/>
- identity>
- endpoint>
- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
- service>
- services>
- <behaviors>
- <serviceBehaviors>
- <behavior name="ServiceBehaviour">
- <serviceMetadata httpGetEnabled="true"/>
- <serviceDebug includeExceptionDetailInFaults="true"/>
- behavior>
- serviceBehaviors>
- behaviors>
- <bindings>
- <wsHttpBinding>
- <binding name="WsHttpBinding" messageEncoding="Mtom" maxReceivedMessageSize="500000000">
- <security mode="None">
- <transport clientCredentialType="None" />
- security>
- binding>
- wsHttpBinding>
- bindings>
- system.serviceModel>
- configuration>
I don't know If I must change only service reference to service 0? or add client endpoints to service 0?
How to check If I'am connected via server 0 or directly to server 1,2?
Sorry for my inaccuracy I'm new in WCF.
Replies
Know the answer? Post it — somebody with the same question will find it here.