/// <summary> /// Register a WCF client proxy for the given service interface with the IOC. The service /// will be contacted at the given URI. /// </summary> /// <remarks> /// <para> /// To register different endpoint behaviours the behaviour must be added to the clientModel (not the endpoint directly like the service registration). /// Adding the endpoint behaviours directly to the endpoint will not invoke the endpoint behaviours. /// </para> /// </remarks> /// <typeparam name="T">service interface</typeparam> /// <param name="k">IoC kernel to register to</param> /// <param name="uri">service URI</param> /// <param name="streamed">true if streaming must be supported</param> /// <param name="maxMsg">maximum message size supported</param> /// <param name="sendTimeout">WCF proxy timeout to send a message</param> /// <param name="receiveTimeout">WCF proxy timeout to receive a message</param> /// <param name="useExternalEndpointBehaviour">Optional: Flag to add external endpoint behaviour (<c>true</c>) or the default endpoint behaviour. Default: false</param> public void RegisterWCFClientProxy <T>(string uri, bool streamed, int maxMsg, TimeSpan sendTimeout, TimeSpan receiveTimeout, bool useExternalEndpointBehaviour) where T : class { var endPoint = GetEndpoint(uri, streamed, maxMsg, sendTimeout, receiveTimeout); try { var clientModel = new DefaultClientModel() { Endpoint = endPoint.At(uri) }; clientModel = clientModel.WithoutAsyncCapability(); var endpointBehaviour = this.CreateEndpointBehaviour(useExternalEndpointBehaviour); clientModel.AddExtensions(endpointBehaviour); Kernel.Register(Component .For <T>() .LifeStyle.Transient .AsWcfClient(clientModel) ); Logger.InfoFormat("WCF CLIENT proxy registered at [{0}]: Endpoint-Behaviour-Count: {1}, Use-External-EndpointBehaviour = '{2}.'", uri, clientModel.Extensions.Count(), useExternalEndpointBehaviour.ToString()); } catch (Exception ex) { var msg = string.Format("Error: WCF client proxy registration failed at address = [{0}], useExternalEndpointBehaviour = '{1}', Ex='{2}'", uri, useExternalEndpointBehaviour.ToString(), ex.ToString()); Logger.Fatal(msg); IoCSetup.ShutdownAndExit(msg, 1); } }
public override IWcfClientModel GetClientModel(params object[] extensions) { IWcfEndpoint endpoint = WcfEndpoint .ForContract <T>() .BoundTo(Binding) .At(Address) .AddExtensions(extensions); DefaultClientModel clientModel = new DefaultClientModel(endpoint); if (OpenOnDemand) { clientModel.OpenOnDemand(); } if (!AsyncCapability) { clientModel.WithoutAsyncCapability(); } return(clientModel); }