WCF – Queryable over SOAP using OData URI’s

Tuesday, September 3, 2013

OData protocol offers a rich and powerful query API over the data exposed from the data service. Usually, the query description is aggregated to the URI of the service operation as the query string, then the service can translate that query back on to the queryable model and return the specific query desired by the client. If you used it before, you must have seen the power it brings you in exposing the data to many clients and platforms to support each and every need. In addition to WCF Data Services, ASP.NET WebAPI has too...
tags: ,
no comments

WCF – Publishing Unreferenced Data Types

Thursday, February 21, 2013

The default behavior of WCF services is to expose schemas in the service metadata of the object data graph that is exposed in the service contract. When consuming the metadata, the default behavior is very similar in the sense that it creates the object data graph that is exposed in the service contract. In some cases you may want to publish additional data as part of the service metadata even though it isn’t referenced somewhere in the service contract, that is other than the fault contracts, parameters object graph, and the return values. How can...
tags: ,
no comments

WCF – Custom Message Encoder and Operation Message Size

Thursday, December 20, 2012

You may find the need to determine the request and reply message size when calling a service operation. It can be for logging purposes, or a practical one such as deciding whether you need to compress the data or not. The key component in WCF that knows about the actual size of the message is the message encoder, and of course, you can plug-in your own encoder as part of WCF’s extensibility point. Ahhh, got to love this framework! Lets examine the feature requirements first - We need to have a...
tags: ,
7 comments

WCF – Should PerCall Care About Concurrency? (And More..)

Tuesday, December 11, 2012

This post discusses several questions: Should ‘PerCall’ services care about the concurrency mode? Can closing the channel block after calling O/W operation? Should you reuse the same proxy instance concurrently? Does the Async Pattern matter in concurrent client? This is quite a long post, but it should be quite interesting , you should download the example here. In order to discuss the matter, let’s establish the scenarios we’re going to test first: About the contract: ...
tags: ,
2 comments

MS DTC – Can’t get it to work? Try Reinstalling – The Proper Way

Thursday, December 6, 2012

Boy that MS-DTC, huh? It can give much trouble, no doubt. If you can’t communicate between two parties and keep failing with errors such as “The flowed transaction could not be unmarshaled”, try the following: Use DNS instead of IP addresses Disable Firewall Remove security and enable the options in the MS-DTC security (in the Component Services shell) Try DTCPing to troubleshoot the case If everything seems to be set properly and you’re still experiencing connectivity issues, you should try...
tags:
no comments

.NET 4.5 Async “ConfigureAwait” – Keep the Synchronization Context in Mind

Saturday, December 1, 2012

I assume you have heard about the great addition in .NET 4.5 – The Async Keyword. It is truly one of the key changes made to the .NET language, and it is awesome. Asynchrony should be part of our code, there’s no escape from that. If you write UI applications – you need asynchrony to avoid blocking the UI thread. If you make I/O operations – you should use its asynchronous model that utilizes the I/O completion threads instead of occupying a worker thread. ...
tags: ,
one comment

WPF PRISM DelegateCommand Wrappers in .NET 4.5

Tuesday, November 27, 2012

If you happened to implement an ‘ICommand’ for your presentation logic in WPF, and decided to contain PRISM’s DelegateCommand within your class and use its own mechanism of the ‘CanExecuteChanged’ event – Beware! Consider the following example - class CommandWrapper : ICommand { private readonly DelegateCommand _command; public CommandWrapper(Action execute, Func<bool> canExecute) { _command = new DelegateCommand(execute, canExecute); } public bool CanExecute(object parameter) { return _command.CanExecute(parameter); ...
tags: ,
2 comments

MEF – Thread Safety and GetExportedValue

Sunday, January 2, 2011

In one of our projects, we encountered odd exceptions that were thrown out of “GetExportedValue<T>” from the CompositionContainer of MEF. There are 2 exceptions that I have seen that are related to the same issue: System.InvalidOperationException: GetExportedValue cannot be called before prerequisite import 'MyType..ctor(Parameter="myParameter", ContractName="MyOtherType")' has been set System.ArgumentException: An item with the same key has already been added. After digging into the matter, we found that these errors occurred while trying to call GetExportedValue concurrently from numerous threads. Yeah, simple as that, MEF isn’t thread-safe in its default form. Following is...
tags: ,
37 comments

WCF – TCP with UserNameToken without Message Security

Sunday, November 7, 2010

There was a project that I assisted with the WCF communications where they needed to allow the client to specify different credentials without being dependent on the windows account. The first thing that comes into mind is to use the UserNameToken technique to pass in the client credentials. The design instructed to use TCP as the transport and not use message security. Obviously, this technique has privacy and integrity issues where there isn’t any encryption nor signing, but that was their decision because it wasn’t an issue in the purpose of the project. Well, this setting isn’t...
tags: ,
4 comments

MEF – Conventional catalog for registering non-attributed parts

Monday, October 18, 2010

As part of the task where I had to upgrade an existing WPF project to PRISM 4.0 and work with MEF, one of the requirements was to support registering existing non-attributed parts. Consider the following example - Code Snippet public interface IFoo { }   public class Foo : IFoo { }   static void Main(string args) {     //This is the desired thing to do     myCatalog.Register<IFoo, Foo>(); } As you can see, type Foo has no export definitions set on it. One...
tags: ,
no comments