Win 7/Win2008 R2 – something I don’t understand

Guys – something that always gets me.

Q. Why when you install Win2K8/R2 out of the box settings have the POWER MODE=balanced???

I’m always amazed by this – there’s 101 other questions + answers you’re asked and
you give. But nowhere does the system say (oh a server system mind you)

“BTW – you know the 8 Cores you have, you’re gonna use 2 of them at any one time”

It’s a Server O/S not a desktop (Desktop I can totally understand
– saving power, greener world etc etc) – server I don’t get.
(The flip side to that coin is – “if the server actually ran at a faster capacity
– I’d be finished in 30 mins instead of 4hrs” -> therefore you save 3.30mins of
green lush rainforest – or some nuclear radiation from entering the world)

I find this power setting is always one of those elusive settings on Server, upon
first start up you get prompted for Roles, Features, Networking even IE
Security Settings
.but nothing about limping along.

You have been warned – you may think “What’s Mick on about”did I tell you about the
TWO production environments I recently visited and they thought I was a miracle worker

I wonder is SCOM 2007 R2 reports that setting back to the main console??

Oh BizTalk, why dost thou mock me?

In any given integration project many different parties are involved. In some cases these parties have standard endpoints against which BizTalk operates and sometimes these endpoints are built as you go in the participating systems to meet a new demand. This is true for other types of projects as well – things get finished at different times – and you need to be able to work independent of each other during that time. What you often do determine very early in the project are the design of messages, schemas or APIs through which you exchange information. In many cases a BizTalk project can effectively use FILE send or receive ports that serve the same purpose as a One-Way send or receive port to say SAP would do at a later stage. But how about solicit-response send ports? What do you exchange these for?

In this post I’d like to introduce a way to handle solicit-response through the use of a catch all WCF Service. There any many ways in which to mock a service. The prime benefit with this approach is that you will be able to model your BizTalk solution the way you want it to be, without having to have access to the real service, and exchange the solicit-response port for it’s production or acceptance test counter parts at your convenience.

To achieve this we need something that let’s us send in any message, and based on some part of the message determine what message to send back, and the send it as a response.

WCF is a perfect candidate. It has functionality both to allow us to create methods that handles all incoming requests by specifying a wildcard (*) as the Action property, and accept any message and can send any message as a return. Using the Message base class it also allows us to easily create the response message, and populate the body of the message from the contents of a stream, such as a file (See the ’Creating Messages from XmlReaders’ topic in the link).

So what I did was I created a WCF Service, and added a method to catch all messages:

[OperationContract(Action = "*", ReplyAction="*")]
Message CatchAll(Message message);

In the implementation for this method I have include the following code:

FileStream stream = new FileStream(ResponseHelper.GetResponseFile(requestAction), FileMode.Open);
XmlDictionaryReader xdr = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas());
MessageVersion ver = OperationContext.Current.IncomingMessageVersion;
return Message.CreateMessage(ver, ResponseHelper.GetResponseAction(requestAction), xdr);

I have a small helper class that just helps me get data from the config, the config in turn looks like this:

<configSections>
  <section name="requestResponseHandling" 
type="ServiceHost.RequestResponseHandlingConfigSection, ServiceHost"/>
</configSections>

<requestResponseHandling>
  <actionList>
    <add requestAction="http://tempuri.org/IService1/GetData2" 
responseAction="http://tempuri.org/IService1/GetData2Response"
responseLocation="GetData2Response.xml" />
  </actionList>
</requestResponseHandling>

This enables me to add new responses to incoming requests without needing to rebuild the service to incorporate a new response. You could go crazy here with code and undertakings to reply based on some context or what not. In the case presented here I’m just making it simple and returning the same static message for all request that matches a certain requestAction.

Finally, put this in the host of your choice. In my case I’ve got IIS so I’m hosting it there. That will also cause changes to the web.config to automatically get loaded, so that’s happy times.

Using this from a client is super easy. Just point the address of the client endpoint towards this service instead. The only thing that might not be super simple (though still fairly simple) is that you need to know what the meat of the response will look like when serialized as a response (the body of the response message). That is you need to Generate a sample response message from your wsdl.

Now let’s look at how we can utilize this to mock services in BizTalk Server. Oh, but wait, that sounds like it would be a bit of work to do, but no, that isn’t the case. In fact, once you have configured the WCF service the only thing you need to do is to point your Send port at this service instead of the system that would otherwise be there in it’s place. Loop closed.

Interviews at ØreDev and Ze Frank!

Tibi and I are winding down after a hectic few days at the %u00d8reDev conference in Sweden. It was a great conference, with a lot of international speakers and attendees, and a good mix of technologies and tracks. One of the highlights was Ze Frank, who was delivering his stand up comedy routine, which was targeted just right for the attendees.
I laid down the gauntlet to Tibi by challenging him to get an interview with Ze, and he accepted and delivered the goods, thanks to Herbj%u00f6rn Wilhelmsen for chatting with Ze to arrange it. We managed to get a slightly longer “5 Minutes With” interview in which Ze turned the tables on Tibi and asked him questions about conquering a fear of flying and his attitude for dealing with the challenges life can throw at us. It’s very refreshing to have an interview without any three-letter-acronyms.
CloudCasts has also had a busy week, as I’ve posted interviews with Scott Hanselmam, Scott Allen, Julie Lerman, Herbj%u00f6rn Wilhelmsen and Magnus M%u00e5rtensson. We even added some music to the site with a splendid rendition of “The Joker” by Carl Franklin, with Shawn Wildermoth providing the guitar solo. If you are ever in Malm%u00f6, I recommend the “The Bishops Arms”, though we could not decide if we should have 8 or 10 Bishops Fingers there. I have another few videos in the can, and will be getting them uploaded over the weekend.
Overall %u00d8reDev 2009 was a great success, big credit to Michael Tiberg for his organization skills and his passion for the event; I’m looking forward to %u00d8reDev 2010 already.
You can see all the %u00d8reDev content here.
To DAL or not to DAL

To DAL or not to DAL

Do BizTalk consultants need to care about Data Access Layers? Does a BizTalk solution really need a DAL?  These are the questions that I’ve been mulling over in the past few weeks. Let me explain.

There are a couple of places where a BizTalk solution encounters a DAL. The first is where the DAL acts as […]

.NET Services November CTP released today

In case you missed it, there was a new release of .NET Services today. LOTS of changes, I’m just starting to digest them now (including some breaking changes, to be expected given that we are at CTP stage).

I really like where this is all heading, and see some interesting new types of applications that we’ll be able to create that would not have been possible without a cloud-based service bus. And better yet, I’m having some of these discussions with customers around real scenarios, leveraging .NET services to solve a lot of distributed application challenges. These are exciting times indeed!

You can read the official announcement and release notes here.

You can download the SDK here.

Retrieving Nested Properties from Lambda Expressions

Normal
0

false
false
false

EN-GB
X-NONE
X-NONE

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}

[Source: http://geekswithblogs.net/EltonStoneman]

Supposing you’re using a lambda expression as a neat way to access a named property:

s => s.FirstName

– when what you really want is to access it without using a string for the property name (“FirstName”), for example to specify the source or target property for a mapping exercise.

It’s easy if the expression is a direct property of the parameter type – a member of the “s” in the expression; casting the whole expression as a MemberExpression gives you access to the member as a PropertyInfo. You can encapsulate it in an extension method of LambdaExpression:

public static PropertyInfo AsPropertyInfo(this LambdaExpression expression)

{

PropertyInfo info = null;

if (expression.Body.NodeType == ExpressionType.MemberAccess)

{

info = ((MemberExpression)expression.Body).Member as PropertyInfo;

}

return info;

}

– which lets you access the property like this:

Expression<Func<FullUser, object>> exp = s => s.FirstName;

PropertyInfo sourceProperty = exp.AsPropertyInfo();

But if the expression represents a property of a nested type, or a property of a nested type of a nested type:

s => s.Address.Line1

s => s.Address.PostCode.Code

– then it’s different.

What you want in this case is an executable expression which will access the containing object of the property (e.g. get you the Address property of the source object, or the PostCode property of the Address property of the source object). You also want the PropertyInfo of the target property (e.g. Line1 or Code). And you want both the property accessor and the PropertyInfo from the same expression.

This is not too difficult. It doesn’t require a stack of target objects and PropertyInfos as originally feared. Firstly store the PropertyInfo from the nested target in the normal way:

targetPropertyInfo = targetExpression.AsPropertyInfo();

– this gives us access to Line1 or Code. Then store the expression which retrieves the path to the containing object for the property from the original source – .Address or .Address.Postcode. In the expression tree, this is the expression which contains the root to the original parameter:

if (targetExpression.Body.NodeType == ExpressionType.MemberAccess)

{

MemberExpression memberExpression = targetExpression.Body as MemberExpression;

if (memberExpression.Expression.NodeType != ExpressionType.Parameter)

{

ParameterExpression parameter = GetParameterExpression(memberExpression.Expression);

if (parameter != null)

{

_targetExpression = Expression.Lambda(memberExpression.Expression, parameter);

}

}

}

The key line is the one which contains Expression.Lambda(). The parent expression is a MemberExpression (e.g. s.Address, or s.Address.PostCode) which itself is not executable. You can’t compile a MemberExpression and execute it on an object to get the member, as the expression needs to know the parameter it executes against.

Expression.Lambda creates a compilable, executable expression against a provided target parameter – which we already have from the “s” of the original expression, and we can find for any level of nesting:

private ParameterExpression GetParameterExpression(Expression expression)

{

while (expression.NodeType == ExpressionType.MemberAccess)

{

expression = ((MemberExpression)expression).Expression;

}

if (expression.NodeType == ExpressionType.Parameter)

{

return (ParameterExpression)expression;

}

return null;

}

So now we have the PropertyInfo for the nested target, and an expression which will give us the nested target, we can set the target property value like this:

object target; //this is the top-level object

//…

realTarget = expression.Compile().DynamicInvoke(target);

targetPropertyInfo.SetValue(realTarget, value, null);

It’s quite a complex requirement, but the solution is straightforward and the complexity is isolated from the calling code. Note that the example code above only deals with nested properties, not expressions with mixed properties and method calls (e.g. s.Address.GetPostCode().InwardCode), but it’s straightforward to cover those cases too.