Thursday, September 27, 2007

WCF inheritance in REST interop scenarios

I am writing Xml that needs to be consumable by any client that can make an HTTP request. I am also trying to write a service API that using inheritance so that i can have a method such as Accept() that can take any object derived from MyBaseClass.

The answer turned out to be easier than i thought, but it was a but of a struggle getting there as most answers are tuned toward your CLIENT also being a WCF client (which is the case in about 5% of my use cases).

The answer is to construct your Xml and use the Xml Schema type attribute to define the type of the object when passing it to a method that accepts its base class.

So if i have a web service method "Accept":

public void Accept(MyBaseClass val);

... and if i have the class MyClass : MyBaseClass , then in code i can simply write:

MyBaseClass bc = new MyBaseClass();
Accept(bc);

Now, to do the same in an XML REST POST WCF scenario, you construct the following Xml:


<val xmlns="http://myns.org" i="http://www.w3.org/2001/XMLSchema-instance" i:type="MyClass"><br />...</val>


Notice the type attribute is used to state the derived class.


Monday, September 24, 2007

BBC Blast in Glasgow

By chance yesterday we wandered into the BBC Blast event in Atlantic Quay, here in Glasgow.

My son Xavier was fascinated as soon as he saw one of our friends on the big screen (she presents the news on TV) and with that and getting a special badge which went around his neck, we weren't going home anytime soon. It wasn't too busy, but the quality was quite high with artists, musicians, reporters, producers and so on all doing various things to keep your attention.

My son even wrote his own news report abut saving the earth from a meteor which is printed and laminated. It was a dangerous walk home as he asked me to read it to him - along with his sister who, at 9 months, discovered the "Franci-saurus" in Chile.

I still think there must be better ways of raising awareness of events in your local area and i'm thinking hard about that just now.

Thursday, September 13, 2007

Wipro and the elephant

I'm reading Bangalore Tiger, the story of Wipro - one of the most successful technical services companies in India and indeed the world.

I have started to look outside of Silicon Valley for inspiration. The problem is that Silicon Valley is a fairly unique community and businesses coming from the Valley have soooo many resources available to them. I read about them and start realizing that most of what they take for granted just isn't available to most of us.

Now, i still love the stories of the big Valley companies, but when i started reading about Wirpo i started to see (and no disrespect intended) a company who hacked around until they got it right. They started off in oil and soaps and now run a 68,000 employee technology company. They are an amazing story of bootstrapping.

I also love the story by Vivek Paul, former vice chairman at Wipro.
He was at a circus on the outskirts of Bangladore and an elephant was tied to a
peg and wasn't trying to break free, despite the fact it easily could. When he
asked the trainer why, he simply said that it has been tied to that peg since it
was a baby and couldn't break free and stopped trying. So in adult life it
continued to believe this and so never tried.


I love this story, as coming from a relatively small country in Scotland there are too many who believe you can't be successful simply because we are small - negativety is a disease! The result against France last night is a good example of this not being the case.

SPAM Frustration

Yet again i have been hit by the problem of emails that SHOULD be getting to me going into my Junk mail. It seems with Hotmail that you either get a load of SPAM in your inbox, otherwise most go into the junk mail - no middle ground. Their SPAM options don't work particularly well either.

A few years back i wrote a short internal paper on intelligent email based on a social network - might be worth looking at it again....