How to decide which WCF binding to choose??!!

יום שלישי, מרץ 1, 2011

Hi, I decided to share a nice diagram that can help you decide which WCF binding you should choose for your application or SOA architecture. (If you can see the entire image you can download it using right click and "Save Picture As...")  
no comments

Sending .NET configuration section over the wire using WCF

יום שני, ספטמבר 7, 2009

Hi, Have you ever needed to implement configuration sections for the application configuration file? Well probably you have. Let's say you want to read the configuration section from your *.config file and send it thru WCF service. The default behavior when working with configuration object is use the System.Configuration namespace that doesn't support WCF. So the question is what can we do? A nice solution is to use the IConfigurationSectionHandler interface and mark the section implementation as a DataContract. It will be something like:     public class MyConfigurationSectionHandler : IConfigurationSectionHandler     {         #region IConfigurationSectionHandler Members           public object Create(object parent, object configContext, System.Xml.XmlNode section)        ...

EXPERT DAYS – אז מה היה לנו שם בהרצאה של אייל ורדי

יום שלישי, אוגוסט 12, 2008

היי, הייתי ביום העיון של אייל ורדי שכלל הרצאה מתקדמת בנושא: WCF INTERNALS אני חייב לציין שהיתה הרצאה מעולה, בתור אחד שעובד עם הטכנולוגיה הזאת באופן מתקדם מאוד ההרצאה חידשה לי מאוד והיתה מעניינת ומקצועית ביותר. בכלל אייל מרצה בגובה העיניים, ואין לו בעיה לומר פה טעיתי בפתרון או פה לא מצאתי בדיוק איך זה עובד שזה רק מראה כמה הוא מקצוען שלא מוכר סיפורים. היה מאוד מעניין לשמוע על הבעיות ועל סוגי הפתרונות שאייל הציע מהנסיון שלו בפרוייקטים שעשה עם הטכנולוגיה. הייתי ממליץ לכל מי שמתחיל או כבר חזק בטכנולוגיה להוריד את דוגמאות הקוד שהיה בהרצאה, כי אני בטוח שזה יועיל לכם מאוד בפיתוח תשתיות...
2 comments

WCF KeepAliveEnabled to false for WS or Basic HTTP binding, What it supposed to do???

יום שני, אוגוסט 4, 2008

Hi All, There is property called KeepAliveEnabled on HttpTransportBindingElement of WS\Basic http binding. This property can be change on the WCF client configuration only in custom binding. On WS\Basic http binding you can reach the KeepAliveEnabled property only using code. Code Example: ServiceHost host; Type serviceType = typeof(MyService); host = new ServiceHost(serviceType);   ServiceEndpointCollection endpoints = host.Description.Endpoints;   foreach (ServiceEndpoint endpoint in endpoints) {      if (endpoint.Name == "wsHttpEndPoint")      {            endpoint.Binding.CreateBindingElements().Find<HttpTransportBindingElement>().KeepAliveEnabled = false;            break;      } }   The default behavior of WCF is to work with KeepAliveEnabled=true, so when WCF client proxy open connection and decide not to close it, the connection stay open because of the keep alive HTTP header (Connection=KeepAlive) that server forward to client. if I...

WCF Best Practices: How to Dispose WCF clients

יום רביעי, יולי 30, 2008

Use of the using statement (Using in Visual Basic) is not recommended for Dispose WCF clients. This is because the end of the using statement can cause exceptions that can mask other exceptions you may need to know about.using (CalculatorClient client = new CalculatorClient()){...} // <-- this line might throwConsole.WriteLine("Hope this code wasn't important, because it might not happen.");The correct way to do it is:try{...client.Close();}catch (CommunicationException e){...client.Abort();}catch (TimeoutException e){...client.Abort();}catch (Exception e){...client.Abort();throw;}

WCF Tips: Achieving High Performance. List of Key Design Decisions and Tuning Parameters

יום חמישי, יולי 3, 2008

When working with WCF especially when middle-tier client applications uses Windows Communication Foundation, you sould always think about performance and take some major design decisions and tuning parameters. WCF client not generated as a proxy via SvcUtil.exe (Relevant more in .NET 3.0. In .NET 3.5 major performance improvement was made on WCF proxy creation). Client shares service contract and schema (model classes as data contract). Cache WCF proxy as a static member One instance, once instance only, ever Still thread-safe based on WCF under-the-covers network connection pool managementChannels created directly via ChannelFactory Hidden static channel exposed as a property Getter/Setter logic does all initialization/abort/recreation as necessary Maintains clean...
8 comments

Did you know that svcutil with /r does not work for MessageContract

I was trying to generate WCF proxy (Client) using svcutil.exe Visual Studio 2008 version. I also need to use the /r parameter of the svcutil.exe, so the generated proxy code will not generate definition for the objetcs from my reference assemblies.The command I use is something like:svcutil.exe /async http://localhost:8080/MyService /r:"C:\My.dll" /tcv:Version35 /out:MyClient.csIn case the assembly My.dll contain .NET object that mark as  the generated proxy still contain definition for the MessageContract objects, so I have to change these objects to DataContract objects and then the generated proxy was created as expected.You also need to remember that if your reference...

WCF Practices: Writing single function for your entire WCF proxy calls

יום שלישי, יולי 1, 2008

Let's say you want that all your WCF proxy calls will come from one function. This could be very useful and save a lot of code.For example you can write your proxy exception handling in one place.Here is the code example that work on .NET framework 3.5 only: // The public function that execute the WCF proxy call public void WCFProxyCall() {    CreateConferenceRequest r = new CreateConferenceRequest();    Func createFunc = a => proxy.CreateConference(a);      CreateConferenceResponse ci = ProxyWrapperOperation(createFunc, r); }     // This is the single point function for the entire WCF proxy calls // Here you can write code for all your WCF proxy calls. private TResult...
tags: ,
no comments