Andru's WebLog

//Comments about technology and software architecture
>MySelf.Persist();

October 2006 - Posts

WCF Extensibility - Part 2

Service Description

 Service Description at Runtime

Figure 2. ServiceDescription at runtime

 

The Service Description is the heart of the service and is created when a ServiceHost or client ChannelFactory is created to describe all aspects of the service, endpoints and behaviors. This description is a logical view of what the WCF runtime is going to build when the Open method on the ServiceHost is executed, and also is used to generate the WSDL and policy metadata for the service. This metadata is exposed through the ServiceDescription class and the Description property on the ServiceHost and can be changed, for example, by injecting behaviors. To build the ServiceDescription information the WCF runtime first reflects over the service types and then it loads the service configuration. This information is then used when you execute the Open method of the ServiceHost to build the runtime.

In the code shown below you can see how the service description information could be accessed and modified:

 

// Construct the ServiceHost
ServiceHost host = new ServiceHost(typeof(EchoService), new Uri(“http://localhost/echo”) );
// Add endpoints to description
host.AddServiceEndpoint(typeof(IEchoService), new BasicHttpBinding(), “”);
// You can access the Description property of the host
Console.Writeline(host.Description.ServiceType);
// And you can change things before calling Open
foreach( ServiceEndpoint endpoint in host.Description.Endpoints )
{
         // Add My behavior to all Http endpoints
         If( endpoint.Uri.Scheme == “http” )
                 endpoint.Behaviors.Add( new MyHttpBehavior() );
}
// Open the Host
Host.Open();

Next post: Building a Custom ServiceHost

Enjoy!

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 23 2006, 02:05 PM by andresv | with no comments
Filed under: , , ,
WCF Extensibility - Part 1

What we have in WCF

WCF has a design that clearly shows a very hard work of many talented people for a long time, and that kind of effort can only be a good thing.

The first thing you note when start working with WCF is the simplicity of the programming model, a thing that COM+ and Enterprise Services was very good at providing some interesting programming models, like declarative programming using attributes, that WCF tried to incorporate.

After that first impression you start digging a little more into the WCF inner workings and you note that it has all the flexibility and extensibility of WSE and Remoting, and then some more, and also supports the communication style of Remoting (although the WCF team doesn't want to encourage its use) side by side with the full Service Orientation support.

As WCF really is the unification of all previous communication technologies and development paradigms for application and integration scenarios, we can expect to find a more complex architecture underneath, and as I said before it can be a little intimidating when you start looking into all those interfaces and options for extensibility.

WCF Architecture

Figure 1. WCF Architecture

As we can see in the simplified architecture diagram shown above, WCF has two main layers where extensibility can be applied and the first decision you have to make is at what layer you need to apply the extensibility you need:

  1. Customizations at the service model level: this is the higher level of abstraction in WCF and they apply to the higher level constructs like service, contracts and operations. Most common customizations are made at this level and they relate to the fact that you can change the local behavior of any of those service constructs.
  2. Customizations at the messaging level: this is the lower level of the WCF infrastructure where you have protocols and transport channels. In this layer the message is serialized and transmitted using the selected transport, also protocol rules are applied (like reliable messaging) and security (like encryption). Customizations here are needed when you need to modify "what's on the wire".

Other extensibility points beyond these two include Bindings, Security, Metadata, Serializers and Hosting but they are somewhat less common in typical applications.

The three ways of customizing the service layer include:

  • Manipulate the Service Description.
  • Injecting Behaviors by hand.
  • Overriding ServiceHost / ChannelFactory<T>.

We are going to dive into these three customization methods in the next posts.

Next post: WCF Service Description Layer

 Enjoy!

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 20 2006, 04:12 PM by andresv | with no comments
Filed under: , , ,
Understanding WCF Extensibility

I have written a white paper on WCF extensibility and I would like to share it with the community so I have attached a copy to this post in Word 2003 format.

 Enjoy!

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 19 2006, 06:15 PM by andresv | with 3 comment(s)
Filed under: , , ,
Upgraded to Vista RC2

Last week I upgraded my personal machine to the Vista RC2 version. It was running RC1 and for the most part it worked well, except for some blue screens and some extrange behavior with my video card making my machine to loose video after some time. This machine had Vista Beta2 but this version started to degrade after some time to the point I couldn't even login. At that time I recovered a backup of everything I needed and perform a clean install of RC1.

The upgrade operation went smooth and I have to say that RC2 is working better for me than RC1, so far no blue screens or loosing video signal!

Anyway, there are some small quirks (like some Sidebar gadgets not working) but nothing critical. I have a nice video board (ATI Radeon 9600XT) so glass is no problem but the ATI drivers are rather buggy. I really expect them to make a better job for the final versions of the drivers.

The general performance is good and so far I have no complains on this release, so give it a try and you will be surprised.

Please remember that for running Vista inside a virtual machine you will need some of the latests (ergo, BETA) versions of Virtual PC or Virtual Server.

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 17 2006, 12:37 PM by andresv | with no comments
Filed under: ,
WS-Compression, WCF and Named Pipes

I found the WCF version of the WSE3 compression filters on the Pablo Cribaro's blog where he published an updated WCF RC1 version.

This code was first released by Morty for WSE2. At that time we (Rodolfo Finochieti and I) make some improvements to that code, and later Rodolfo migrated this code to WSE3. Is very interesting how the community works....

The thing is the WCF version was having problems when used over a Named Pipes transport, so I decided to take some time and discovered some interesting behavior.

The problem occured in the ReadXml method of the CompressionMethod.cs class, and only fails when using TCP or NamedPipes, not on Http. So after doing some debugging I found that in the case of the Http transport, when the Xml Reader was reading an XmlNode with attributes it first reads the StartElement and after that an EndElement. This behavior changes when you are using Named Pipes and after reading the XmlNode that has some attributes, the reader skips the EndNode completely and positions itself on the nect XmlNode.

I first made a quick fix just by asking the XmlReader if the next node was an EndElement before trying to execute a ReadEndElement, but it seems too much as a hack so I tryied another approach.

In the attached file I publish an updated version of the compression library for WCF (for RC1) and modified the CompressionMethod.cs so it doesn't use attributes anymore, and in that way it works as expected regarding the transport being used.

If you ask me it looks like a bug on the XmlReader, because both messages was exactly the same (checked with trace) and this different behavior is totally unexpected.

I found other bug related to the use of Request/Reply channels with void contract methods. In that case a NULL message was sent back as response and therefore the code fails. On the CompressionInterceptor.cs class I have to check if the passed message was equal to null in the Compress and Decompress methods, and everything works as expected now.

Enjoy!

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 12 2006, 07:37 PM by andresv | with no comments
Filed under: , , , ,
PowerThreading ThreadPool with propagation

I have been playing with the cool PowerThreading library created by Jeffrey Richter from Wintellect (found in http://www.wintellect.com/MemberOnly/PowerThreading.aspx ) and replaced an old implementation of a custom thread pool we already had.

The thing is we needed to propagate the caller thread information (CAS, Execution Context, Culture) to the worker threads, so I modified the CallbackThreadPool.cs class provided in the library to give the new class those features.

The new class is called PowerThreadPool.cs and is included as an attachment in this post.

Enjoy!

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 09 2006, 06:00 PM by andresv | with 1 comment(s)
Filed under: ,
Retina.NET 1.0.8.0 Released

You can download the latests Retina.NET version from http://workspaces.gotdotnet.com/retina  

This include the VS.NET 2005 solution projects with all Core, DataStore and Tests in Retina.NET.
Please note that this version of the sources is not VS2003 solution, and therefore can be debugged in VS2005 but it must be compiled using MSBUILD command line and MSBEE 1.0 for generating NET 1.1 assemblies from a VS2005 solution.
For your convenience I have included two CMD files: build.cmd and build_release.cmd, both found in the root of the solution folder.
Please note that the private key used for Retina.NET strong name is not distributed, but all projects are configured to use delay signing with the Retina.NET public key and therefore you must skip verification of Retina.NET debug assemblies.
The sources are provided for viewing/learning/debugging only, and if you are going to use Retina.NET in a project is recommended to use the official binaries. If you make any changes or improvements to Retina.NET you are encouraged to submit this changes to te author so it can provide you an official Retina.NET release.


This is an INTERIM RELEASE

  • Documentation and QuickStart document is not provided. 
  • Some samples may not work, specially the Portal application, and therefore not provided in the sources..
  • EntityGen and EntityGen2 projects are untested, and therefore not provided in the sources.
  • Installers are not included in this release.

    Retina.NET config file format is changed


Main changes introduced in this release: 

  • Full support for using stored procedures for persistence and Criteria queries. 
  • Fixed Nullable TEXT column generation in all DataStoreBuilders. 
  • Changed reference to Castle.DynamixProxy v1.0.5.0 for including the latests fixes. 
  • Changes in the ChildCollection class to enforce duplicate policy during Insert or Remove. 
  • Created the AuditManager class for application audits (trace) of executed commands. 
  • Delete triggers now fire as expected. 
  • Fixed the loading of child entities when an entity has more than one relationship with the same child entity. 
  • Proper support for Criteria objects on inherited entities, no matter what persistence model is used (joins or not). 
  • Change in ObjectContext constructor to use CodeBase instead of Location. This allows Retina to run under shadow folders. 
  • Support for COM+ v1.5 transactions without the need of an EnterpriseServices component.
I have made a specially strong effort to eliminate any remaining bug so any feedback on that would be welcome.

This version has suffrered some deep refactoring and all this changes will be integrated into the NET 2.0 version. In fact, I'm currently working on merging both versions into a single VS2005 solution.

Best regards,

Andrés.

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

Posted: Oct 09 2006, 05:39 PM by andresv | with no comments
Filed under: , , ,
I'm back online

Well, I have been out of the blogosphere for quite some time, but now I'm back!

I'm extremely busy working in very interesting stuff, so I have some good stuff to comment and share about.

Best regards,

Andrés.

Andrés G Vettori
MCSE/MCSD/MCT
EDS Top Gun - .NET Capability Architect

Leader of the C# Community of the Microsoft Users Group Argentina

More Posts