// // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // .Net StockTrader Sample WCF Application for Benchmarking, Performance Analysis and Design Considerations for Service-Oriented Applications //====================================================================================================== // This is the client for the OrderProcessorService. //====================================================================================================== //====================================================================================================== // Code originally contributed by Microsoft Corporation. // This contribution to the Stonehenge project is limited strictly // to the source code that is submitted in this submission. // Any technology, including underlying platform technology, // that is referenced or required by the submitted source code // is not a part of the contribution. // For example and not by way of limitation, // any systems/Windows libraries (WPF, WCF, ASP.NET etc.) // required to run the submitted source code is not a part of the contribution //====================================================================================================== using System; using System.Diagnostics; using System.Data; using System.Collections.Generic; using System.Text; using System.ServiceModel; using System.Threading; using System.ServiceModel.Channels; using System.Runtime.Serialization; using System.Globalization; using System.Reflection; using Trade.Client; using Trade.Utility; using System.Configuration; using Trade.ConfigServiceContract; using Trade.ConfigServiceDataContract; namespace Trade.ConfigClient { /// /// This is the WCF client class for the remote Order Processor Services. This class implements channel initialization and /// load balancing/failover logic across cached channel instances specific to the Configuration Management/Node services /// implemented in StockTrader via the LoadBalancingClient.Client class, now re-used across all clients /// implementing the configuration service. /// public class ConfigServiceClient : IConfigService { public Client.Client csclient; /// /// This will initialize a new Config Service Client /// The endpoint for the ConfigService needs to be specified in the config file of the application calling this Client /// public ConfigServiceClient() { //Changed this from Settings.CS_DOTNET_ENDPOINT to remove the dependency on settings //Now one config client can be used that's common to the Business Service, OPS and Trade Client csclient = new Client.Client(ConfigurationManager.AppSettings.Get("CS_DOTNET_ENDPOINT_CONFIG_HTTP")); } /// /// This returns the base channel type, cast to the specific contract type. /// public IConfigService Channel { get { return csclient.Channel; } set { csclient.Channel = value; } } /// /// A Static method that clears the cache of the Client Service /// public static void Initialize() { Client.Client.ClearCache(); } #region IConfigService Members public ClientConfigResponse GetClientConfig(ClientConfigRequest client) { try { return this.Channel.GetClientConfig(client); } catch { this.Channel = null; throw; } } public BSConfigResponse GetBSConfig(BSConfigRequest bs) { try { return this.Channel.GetBSConfig(bs); } catch { this.Channel = null; throw; } } public OPSConfigResponse GetOPSConfig(OPSConfigRequest ops) { try { return this.Channel.GetOPSConfig(ops); } catch { this.Channel = null; throw; } } public void SetClientToBS(ClientToBS clientConfig) { try { this.Channel.SetClientToBS(clientConfig); } catch { this.Channel = null; throw; } } public void SetBSToOPS(BSToOPS bsConfig) { try { this.Channel.SetBSToOPS(bsConfig); } catch { this.Channel = null; throw; } } public ServiceLocation[] GetBSLocations() { try { return this.Channel.GetBSLocations(); } catch { this.Channel = null; throw; } } public ServiceLocation[] GetOPSLocations() { try { return this.Channel.GetOPSLocations(); } catch { this.Channel = null; throw; } } public void SetServiceLocation(ServiceLocation location) { try { this.Channel.SetServiceLocation(location); } catch { this.Channel = null; throw; } } #endregion } }