channelfactory

How do I create a simple Web Server using WCF without the ServiceHost class?

落爺英雄遲暮 提交于 2019-12-03 10:01:15
I've began to learn WCF and wish to understand its internals by creating a simple Web server using channel stacks directly. I have found a lot of theory in the web but I'd like to see a working sample code of receiving and responding an httprequest that I can test using any browser. I'm hoping for something that shows the setup of a custom binding by assembling binding elements all the way to responding the request. Got the answer in MSDN forums : static void RunService() { //Step1: Create a custom binding with just TCP. BindingElement[] bindingElements = new BindingElement[2]; bindingElements

Direct Channel usage vs using a Proxy?

爱⌒轻易说出口 提交于 2019-12-03 09:44:38
问题 As the title implies I am trying to get an understanding of why in WCF sometimes people choose to "generate proxies" vs using a ChannelFactory to manually create new channel instances. I have seen examples of each, but haven't really found any explanations of WHY you would go for one vs the other. To be honest I have only ever worked with channels and the ChannelFactory<T> from code I have inherited, ie: IChannelFactory<IDuplexSessionChannel> channelFactory = binding.BuildChannelFactory

WCF ChannelFactory and Channel caching in ASP.NET client application

▼魔方 西西 提交于 2019-12-03 07:37:59
I'm building a series of WCF Services that are going to be used by more than one application. Because of that I'm trying to define a common library to access WCF services. Knowing that each service request made by different users should use a different Channel I'm thinking in cache the Channel per-request ( HttpContext.Current.Items ) and cache the ChannelFactory used to create the channel per Application ( HttpApplication.Items ) since I can create more than one channel with the same ChannelFactory . However, I have a question regarding this cache mechanism when it comes to closing the

WCF ChannelFactory and channels - caching, reusing, closing and recovery

耗尽温柔 提交于 2019-12-03 07:26:18
问题 I have the following planned architecture for my WCF client library: using ChannelFactory instead of svcutil generated proxies because I need more control and also I want to keep the client in a separate assembly and avoid regenerating when my WCF service changes need to apply a behavior with a message inspector to my WCF endpoint, so each channel is able to send its own authentication token my client library will be used from a MVC front-end, so I'll have to think about possible threading

why an object of WCF service contract interface can be casted to IClientChannel

允我心安 提交于 2019-12-02 05:44:50
问题 In WCF Client Architecture, it says When using the ChannelFactory class with a service contract interface, you must cast to the IClientChannel interface to explicitly open, close, or abort the channel So you create and use the client channel object like this: var cf = new ChannelFactory<ICalculator>(binding, ea); var channel = cf.CreateChannel(); double result = channel.Add(5.2, 3.5); Console.WriteLine(channel.GetType()); // outputs ICalculator Console.WriteLine(result); ((IClientChannel

why an object of WCF service contract interface can be casted to IClientChannel

孤街醉人 提交于 2019-12-02 02:07:07
In WCF Client Architecture , it says When using the ChannelFactory class with a service contract interface, you must cast to the IClientChannel interface to explicitly open, close, or abort the channel So you create and use the client channel object like this: var cf = new ChannelFactory<ICalculator>(binding, ea); var channel = cf.CreateChannel(); double result = channel.Add(5.2, 3.5); Console.WriteLine(channel.GetType()); // outputs ICalculator Console.WriteLine(result); ((IClientChannel)channel).Close(); There are two things that confused me here. The method signaure of CreateChannel , as

WCF Error : Manual addressing is enabled on this factory, so all messages sent must be pre-addressed

时间秒杀一切 提交于 2019-11-30 10:43:45
I've got a hosted WCF service that I created a custom factory for, so that this would work with multiple host headers: /// <summary> /// Required for hosting where multiple host headers are present /// </summary> public class MultipleHostServiceFactory : ServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { List<Uri> addresses = new List<Uri>(); addresses.Add(baseAddresses[0]); return base.CreateServiceHost(serviceType, addresses.ToArray()); } } I'm pretty sure that my config files are now right, on both client and server ( can be seen

WCF Channel and ChannelFactory Caching

安稳与你 提交于 2019-11-29 20:30:11
So I've decided to up the performance a bit in my WCF application, and attempt to cache Channels and the ChannelFactory. There's two questions I have about all of this that I need to clear up before I get started. 1) Should the ChannelFactory be implemented as a singleton? 2) I'm kind of unsure about how to cache/reuse individual channels. Do you have any examples of how to do this you can share? It's probably important to note that my WCF service is being deployed as a stand alone application, with only one endpoint. EDIT: Thank you for the responses. I still have a few questions though... 1

ChannelFactory.Close VS IClientChannel.Close

被刻印的时光 ゝ 提交于 2019-11-28 17:14:01
Consider the following code which is typcial of many ChannelFactory examples: WSHttpBinding myBinding = new WSHttpBinding(); EndpointAddress myEndpoint = new EndpointAddress( ConfigurationSettings.AppSettings["HelloWorldServiceURL"]); ChannelFactory<IHelloWorldService> myChannelFactory = new ChannelFactory<IHelloWorldService>(myBinding, myEndpoint); IHelloWorldService proxy = myChannelFactory.CreateChannel(); ((IClientChannel)proxy).Open(); HelloWorldDataContract dc = proxy.SayHello(); ((IClientChannel)proxy).Close(); Note that when proxy.Open() is called, both the the channel's state and the

WCF Channel and ChannelFactory Caching

落爺英雄遲暮 提交于 2019-11-28 16:03:11
问题 So I've decided to up the performance a bit in my WCF application, and attempt to cache Channels and the ChannelFactory. There's two questions I have about all of this that I need to clear up before I get started. 1) Should the ChannelFactory be implemented as a singleton? 2) I'm kind of unsure about how to cache/reuse individual channels. Do you have any examples of how to do this you can share? It's probably important to note that my WCF service is being deployed as a stand alone