Monday, February 1, 2010

Autodesk Map3d 2010 and WCF (I)

Author: Jonio, Dennis

Well, I finally finished my first Windows Communication Foundation(WCF) project. Ever since .NET Framework 3.0 came out I had been curious but until now the chance to delve into it just never appeared. The prompt was to get some flexibility into the IPC chores between my custom Autodesk application modules(netloads) and my .NET applications.
First off, I certainly join the chorus that promotes getting Juval Lowy’s work Programming WCF Services (in my case 2nd Edition). There is a multitude of nuance and subtlety that would be left to chance without reading this work. In addition I do not have a clue where else a person would go to get his kind of depth of understanding. A real "must have" if you are serious about WCF.
As I spent more time with WCF I certainly learned of some of its strengths and weakness’. I really did waiver a lot concerning implementing the callback interface versus just using the simplest of operation contracts with each executable acting as a hosting service and likewise a client. This would have made this new interface very similar to my previous NamedPipe interface in that both sides act as host and client. In the end I choose the WCF DuplexChannel/callback paradigm because I figured out the rather straightforward way to keep the session(s) alive over an extended period of time.
If you are at all familiar with my previous work with IPC you know that I pass serialized datasets around as opposed to passing more granular objects. I do not stray from this paradigm. It has served me well and I cannot think of any reason to change.

The following are my interface definitions for the service and callback. I will leave the class implementation for a follow up.
Source code (C#):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace DplXByteSrvcs
{
[ServiceContract(Namespace = "WCF.MDAD.SERVICES",
CallbackContract = typeof(IByteSrvcCallback),
SessionMode = SessionMode.Required)]
public interface IByteSrvcWCallback
{
[OperationContract(IsOneWay = true)]
void ControlPacket(byte[] baIn);

[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
int PipedIn(byte[] data);

[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
int DQPipedIn(string destinationQ, byte[] data);

[OperationContract]
Guid Subscribe();
[OperationContract(IsOneWay = true)]
void UnSubscribe(Guid clientId);
[OperationContract(IsOneWay = true)]
void NoOpButKeepAlive();

}
public interface IByteSrvcCallback
{
[OperationContract(IsOneWay = true)]
void SentControlPacket(byte[] baOut);
}
}

No comments:

Post a Comment