BizTalk presentations in the summer/fall, part two
23 June 10 04:20 PM | Johan Hedberg | 3 comment(s)

I case anyone has missed it, BizTalk User Group Sweden, is as active as ever. We’ve got two great events planned after the summer.

Date: 26/8 2010 - Evening event.
Location: Stockholm
Topic: Managing your BizTalk environment using System Center Operations Manager 2007 R2
Speaker: Kent Weare
Sign-up: Here

This is a great event not only for BizTalk Developers and Operations but also for IT-professionals working with System Center, especially if they have BizTalk in their environment.

Date: 8-9/9 2010 – Yes, that’s right, this is a TWO DAY event.
Location: Stockholm
Topic: Applied Architecture Patterns on the Microsoft Platform aka BizTalk Server 2010 – Release party
Speaker: Richard Seroter, Ewan Fairweather, Stephen W. Thomas
Sign-up: Here

These are both events you do not wan’t to miss, and it seems people agree. Slots are filling up fast so be sure to be quick about signing up.

Filed under: ,
BizTalk presentations during the summer, part one
23 June 10 04:03 PM | Johan Hedberg | with no comments

I’ll be presenting at Microsoft Swedens “Sommarkollo”. I’ll be talking about BizTalk. Introducing it, showing of enhancements in 2010 and going through some (what I hope are) inspirational scenarios. The target audience are developers or architects. Even though I will spend some time in the beginning at an introductory level I believe there are things that will entertain even more seasoned developers. Level is 200-300.

More info about this and other presentations can be found at http://www.microsoft.com/sverige/sommarkollo/default.html

Also, signups for my presentations can be reached through the below links:

Date: 30/6 kl. 13-16
Location: Göteborg
Sign-up: Here

Datum: 1/7 kl. 9-12
Location: Malmö.
Sign-up: Here

Datum: 7/7 kl. 9-12
Location: Stockholm
Sign-up: Here

Datum: 24/8 kl. 9-12
Location: Stockholm
Sign-up: Here

Enjoy the summer! I know I will :)

PS. Just to make readers (especially those from other countries with less generous terms) jealous I’ll be on vacation/parental leave (and have been for two weeks) until the very last days of august.

Filed under: ,
Visual Studio (BizTalk Server) 2010 development / BizTalk Server 2009 deployment mix
23 June 10 03:52 PM | Johan Hedberg | 1 comment(s)

Can you use the updated development environment for BizTalk Server 2010 with Visual Studio 2010 while still deploying to BizTalk Server 2009?

Can you do it? On a file level, yes. On a project level, yes. On a solution level, doesn’t seem like it. On an assembly level, no.

I tried two scenarios.

  1. A simple messaging only scenario with a transformation on the receive port.
  2. An orchestration scenario picking up the file from the receive location, doing the mapping and delivering it to the send port.

I developed the solution on a BizTalk Server 2010 / Visual Studio 2010 combo and deployed it to BizTalk Server 2009.

So what worked and what didn’t?

Compile and deploy the .NET 4 assembly to BizTalk Server 2009

FAIL!

Why?

Even though I did Add a resource manually selecting the file to be a BizTalkAssembly BizTalk Server 2009 kept on reverting it back to File. Obviously it doesn’t recognize it, or recognizes that it’s an incorrect version of the framework.

image

Re-target the solution to .NET 3.5 or .NET 2.0

FAIL!

Why?

The following is taken from http://msdn.microsoft.com/en-us/library/ff629735(BTS.70).aspx

BizTalk Server 2010 supports building new applications only on .NET Framework version 4 . You can build both BizTalk applications as well as custom applications (such as custom functoids, custom pipeline components) using .NET Framework 4 . However, BizTalk Server 2010 continues to support the BizTalk Server 2006 R2 and BizTalk Server 2009 applications (BizTalk applications and custom applications) built on .NET Framework 3.5 SP2.

If you launch an existing BizTalk project in BizTalk Server 2010 , it automatically gets migrated, changing the .NET Framework version to 4.0. You cannot modify the .NET version number later in the Properties dialog box of the BizTalk project.

In essence it says that you cannot use the re-targeting functionality within Visual Studio 2010 for BizTalk Server 2010 projects. If you try, because the drop down is still there, you get the following dialog:
image

Using Files created by Visual Studio 2010, like .xsd, .btm or .odx

SUCCESS!

You can copy paste files from one project into another, without any issues I detected.

Open the project file created with Visual Studio 2010 and re-compile using Visual Studio 2008

SUCCESS! But with some issues…

You can open a BizTalk project created in Visual Studio 2010 in Visual Studio 2008 and just re-compile it. Without any issues I detected. However, it does not seem like Visual Studio 2008 wants to open the solution file, which may be an issue in some situations, like for example if you wan’t to create automated builds. The structure of the solution file begins like this:

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizTalk Server Project1", 
"BizTalk Server Project1\BizTalk Server Project1.btproj", "{DE7C19FB-A5BA-46A0-9382-ACFB3EB91409}"

This may very well be what causes Visual Studio to dismiss it.

Hope this helps someone thinking along these lines :)

Disclaimer: This is tested with BizTalk Server 2010 Beta. All artifacts used while performing these tests are trivial. It might very well be that in some more complex scenario this might not work.

Weird MSMQ issue with an even weirder solution
20 April 10 10:59 PM | Johan Hedberg | 2 comment(s)

You may think I am crazy… In fact, it seems so unbelievable I don’t quite believe it myself, but I experienced it, and can’t shrug it off. So, on the off chance that someone else might run into this, I am writing down the experience since I couldn’t find a single reference to it when I searched for a solution (which by all means in turn means it’s unlikely that it has happened to all that many people before).

On one environment I was testing MSMQ connectivity. From my brand new BizTalk Server 2009, windows Server 2008 64-bit, environment I wanted to connect to a Windows Server 2003 remote transactional MSMQ queue. Since I wasn’t doing anything remotely service oriented, quite the opposite – it was all about file transfers, I decided to use the “old” MSMQ adapter.

This didn’t work, and failed with the error message:

The adapter "MSMQ" raised an error message. 
Details "The type initializer for '<Module>' threw an exception.".

Ok. So faced with this what do I do? I start local. I created a local private transactional queue, a FILE receive and a MSMQ send – to get a message into the queue. This worked fine.

I then wanted to read the message out from the queue and write it back to disk. This did not work, but failed with the same error message.

I created a second queue, non-transactional, and put a message in there and tried to read it from that, to peel away the transactional aspect. Same non-helpful exception.

I was somewhat at a loss. As I expressed my disgust a colleague asked why I didn’t use the WCF-NetMsmq, and though I had no intention of using it in the final solution that brought on the idea of trying that instead. So I configured a port for that and enabled it.

When I did, I got back the message from the queue. However… as I looked in the Event Log I saw error messages from that adapter and looked to see that I had configured it incorrectly – I had continued to put the queue name as xxx\private$\yyy (in the WCF-NetMsmq adapter you don’t use the $). What had happened? I had not gotten the messages with my WCF-NetMsmq port.

As I enabled the WCF-NetMsmq the old MSMQ ports had sprung to life and begun working!

I could now get messages from the local transactional as well as non-transactional queue.

And when I tried the remote queue I now got another, much more helpful, error message:

The adapter "MSMQ" raised an error message. 
Details "This operation is not supported by the remote Message Queuing service.
For example, MQReceiveMessageByLookupId is not supported by MSMQ 1.0/2.0,
or remote receive of the large mesasage cannot be done by the client below v3.5

As it turns out, I can’t make the connection I wanted, as remote transactional queues are not supported by the BizTalk MSMQ adapter in this scenario, on accounts of it not being available in Message queuing 3.0 (which, if you remember, my target system is running since it’s Windows Server 2003). References are here:
· http://msdn.microsoft.com/en-us/library/aa562010(BTS.10).aspx
· http://blogs.msdn.com/johnbreakwell/archive/2007/12/11/how-do-i-get-transactional-remote-receives.aspx
· http://blogs.msdn.com/johnbreakwell/archive/2008/05/21/remote-transactional-reads-only-work-in-msmq-4-0.aspx

But the real point here is not that, but the strange exception I got up front. Repro you ask? Couldn’t get it to happen on any other environment, in fact, on the ones I tried the MSMQ adapter just works. No weird exceptions.

Send Failures, NACKS and SOAP Faults
15 April 10 06:22 PM | Johan Hedberg | with no comments

(or why my previous post doesn’t apply to all adapters)

In a previous post I identified how if you had the WCF-BasicHttp adapter on the backend send and the WCF-NetTcp adapter on the frontend receive you need a transformation for the client to interpret the backend Fault as a Fault since there is a SOAP version mismatch.

As was evident by a comment, this does not apply to all adapters, but only to the base WCF adapters. for example it does not work with the WCF-SQL adapter.

Why?

In contrast to the base WCF adapters, which when you enable the Propagate fault message treats a SOAP Fault coming from the recipient service as an acceptable message and returns it to the receive port as a valid SOAP Fault message that has Fault as the root element, the WCF-SQL adapter returns a NACK message (if there is an error raised in SQL) as the message. The NACK message has not got the Fault element as it’s root, but instead has Envelope, and looks like this:

<?xml version="1.0" encoding="utf-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP:Body>
    <SOAP:Fault>
      <faultcode>Microsoft BizTalk Server Negative Acknowledgment </faultcode>
      <faultstring>An error occurred while processing the message, refer to the details section for more information </faultstring>
      <faultactor>C:\Projects\Sample\Locations\Response\FM_%MessageID%.xml</faultactor>
      <detail>
        <ns0:NACK Type="NACK" xmlns:ns0="http://schema.microsoft.com/BizTalk/2003/NACKMessage.xsd">
          <NAckID>{FFB1A60B-E593-4620-8897-4E9C7030A937}</NAckID>
          <ErrorCode>0xc0c01658</ErrorCode>
          <ErrorCategory>0</ErrorCategory>
          <ErrorDescription>There was a failure executing the send pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLTransmit, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "XML assembler" Send Port: "Failed Message" URI: "C:\Projects\Sample\Locations\Response\FM_%MessageID%.xml" Reason: This Assembler cannot retrieve a document specification using this type: "http://Sample#Unknown".  </ErrorDescription>
        </ns0:NACK>
      </detail>
    </SOAP:Fault>
  </SOAP:Body>
</SOAP:Envelope>

Therefore it cannot be mapped by the map presented in that post, although the Fault it contains is a SOAP 1.1 Fault.

Read more about ACK and NACK messages here.

Filed under: , ,
BizTalk and SOAP Fault version issues
08 April 10 08:34 PM | Johan Hedberg | 4 comment(s)

A developer in the same team made me aware of an issue they were seeing where if the BizTalk Send Port returned an exception the Client that called the ReceivePort would get a response that was interpreted as null instead of as an exception.

Now this is a synchronous service call without any orchestration, where BizTalk is just a broker of the web service calls. What we want out of it is this:

  1. For exceptions throw by the backend service to get relayed back to the original caller.
  2. For no suspended messages to be visible in BizTalk when an exception occurs with the backend service – so that operations won’t be bothered with removing them.
  3. For operations to get notified of all other exceptions, ie suspended messages.

Now this is all quite easy, all you need to do is make sure the propagate fault flag is checked on the send port adapter settings:
image
(somewhat shortened dialog)

What can happen though is that when the SOAP version does not match between what the Send Port receives and relays and what the client that called the Receive Port/Location is expecting is that the Fault ends up not being correctly formatted and thus the client is unable to interpret it.

This happens when you use the BasicHttp adapter or BasicHttpBinding with the Custom Adapter on the Receive Port and NetTcp (or WSHttp or… etc) on the Send Port (or vice versa). It happens because the SOAP version that BasicHttp uses is different than that used by the other WCF Adapters.

A sample SOAP 1.1 Fault look like this:

<s:Fault>
  <faultcode>s:Client</faultcode>
  <faultstring xml:lang="sv-SE">You entered 666</faultstring>
</s:Fault>

(where the namespace s is defined on the envelope and points to xmlns:s="http://schemas.xmlsoap.org/soap/envelope/")

While a sample SOAP 1.2 Fault look like this:

<s:Fault xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Code>
    <s:Value>s:Sender</s:Value>
  </s:Code>
  <s:Reason>
    <s:Text xml:lang="sv-SE">You entered 666</s:Text>
  </s:Reason>
</s:Fault>

In our scenario, with the type of metadata that BizTalk exposes for the service, what happens at the client is that what is actually a Fault instead gets interpreted as a valid response, but since the element that represents the response, let’s call it GetDataResponse just for sake of illustration, is missing – the client will interpret it as a null response. Highly unwanted.

The solution is to make sure that the Fault response is valid for the version of SOAP used by the receive side adapter, that is; do a transformation. A transformation can be done in many places: a map, a pipeline component, a WCF Message Inspector. In my case I prefer to place the component resolving the problem as close as possible to the thing causing the problem – which here means I opt for the Message Inspector, but a map might be the easiest for many. I might add the implementation of the message inspector in a later post, but for now, below is some custom xslt you can use in a map (or elsewhere) (if you do not use custom xslt you might get complaints from the client that the namespace prefixes are incorrect for reserved namespaces) – it maps from SOAP 1.1 to SOAP 1.2 (from BasicHttp to others, like NetTcp). You might perhaps also have to map in the other direction.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
                xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" 
                exclude-result-prefixes="msxsl var s0" version="1.0" 
                xmlns:s0="http://schemas.xmlsoap.org/soap/envelope/" 
                xmlns:xml="http://www.w3.org/XML/1998/namespace" 
                xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:template match="/">
    <xsl:apply-templates select="/s0:Fault" />
  </xsl:template>
  <xsl:template match="/s0:Fault">
    <s:Fault>
      <s:Code>
        <s:Value>
          <xsl:value-of select="faultcode/text()" />
        </s:Value>
      </s:Code>
      <s:Reason>
        <s:Text xml:lang="sv-se">
          <xsl:value-of select="faultstring/text()" />
        </s:Text>
      </s:Reason>
      <xsl:if test="faultactor">
        <s:Role>
          <xsl:value-of select="faultactor/text()" />
        </s:Role>
      </xsl:if>
      <xsl:for-each select="detail">
        <s:Detail>
          <xsl:value-of select="./text()" />
        </s:Detail>
      </xsl:for-each>
    </s:Fault>
  </xsl:template>
</xsl:stylesheet>
Filed under: , ,
TechDays Sweden 2010
25 March 10 09:37 PM | Johan Hedberg | with no comments

techdays-blogg-speaker

That should read… I was a speaker at the Swedish TechDays, since I am writing this post after the fact, although I’m backdating the post a bit to more closely match in time when I was supposed to have published it.

I did a session titled “The Future Roadmap of BizTalk Server” and I’m happy to say I drew a full room (not that the room was all that big, but all the same). Future in this case meant I covered both current and coming technology. The reasoning behind it was that a lot of people probably wouldn’t have BizTalk Server 2009. This turned out to be true since it was a clear minority of the people in the room that raised their hands when asked if they had had previous contact with BizTalk Server 2009. I covered ESB Toolkit 2.0 and Itinerary processing as well as connecting to Windows Azure Platform Service Bus. I was a little surprised here that as I asked for a raise of hands on how many were familiar with the Service Bus only a couple of hands went up. Either it’s a Swedish mentality thing – to not want to stand out – or there simply aren’t all that many people interested in it, yet. I went on to cover some of the news in 2009 R2 (which I learned had gotten renamed to 2010 the evening after my presentation). I couldn’t demo anything, but am quite satisfied with how the Powerpoint “Demo” I was able to do (yes, I know, you can kill a presentation, and other things, with Powerpoint, but I think I did ok). I also related some of the vision given by the team at PDC in November and subsequent WebCasts about vNext. The recorded session should be up soon at the TechDays site, however it will be in Swedish, so for an international audience it will be useless. The presentation will be availble soon as well, as a pdf.

Because I believe in sharing I’ve decided to make the presentation available through the blogical Downloads section, here. I have myself borrowed small parts and ideas from the presentation from elsewhere as you often do, but almost all slides and images are built from scratch. I’m sharing those under a “if you decide to use parts of it please at least tell me that you liked it and that it was useful to you through commenting this blog post” license. I’ve marked it as final, but it’s not copy protected or in pdf format or anything, it’s the pptx file itself. Enjoy.

UPDATE: Recorded session (in swedish) is here.

Also BizTalk User Group Sweden was represented at TechDays as well.


(Not the best of pictures, with the backlight and all, but there we are… From MPN Swedens photostream)
Must have hotfixes for BizTalk Server 2009 Developers
26 February 10 06:05 PM | Johan Hedberg | with no comments

Hotfix for resolving issues with references between projects: http://support.microsoft.com/?kbid=977428

Hotfix for problem with orchestrations saying “The expression that you have entered is not valid.” when they are in fact valid: http://support.microsoft.com/?kbid=979153

Filed under:
BizTalk Server 2009 Training
12 January 10 08:02 PM | Johan Hedberg | with no comments

During the fall of 2009 I teamed up with fellow MVP Mikael Håkansson and delivered internal training to Logica employees in Sweden. Training in part based upon existing training material from Microsoft but with presentation material that we made especially for this course. We have since developed this material even further.

Being a MCT I was contacted by one of the major certified learning providers in Sweden that through mutual contacts had learned of what we had done. I have the pleasure of being able to start this year by announcing that an agreement have been reached with AddSkills to deliver this course to the public.

So if you are in my part of the world (a.k.a. Sweden) you now have an additional choice to get quality BizTalk Server training that covers the latest version. See available sign-up details and dates here. Delivery of custom on or off site courses based on the same material is also possible.

PDC09 After Party with Swedish .NET User Group
24 November 09 01:06 PM | Johan Hedberg | with no comments

I’ll be doing a talk on AppFabric at the Swedish .NET User Group tomorrow at 6 pm in Stockholm hosted at Informator. Others will talk about other interesting topics from PDC as well. More info (in swedish) and sign-up at http://pdc2009afterparty.eventbrite.com/

BizTalk Server 2009 Standard and 64-bit processing
23 November 09 11:57 PM | Johan Hedberg | 3 comment(s)

I was kind of suprised when I saw this blog post. Saying that 64-bit processing wasn’t allowed with Standard Edition of BizTalk. Since I was at PDC at the time I asked the people there who were (without me putting words in their mouths) equally suprised. At the time they couldn’t see either a licensing or technical reason as to why that would be so. And to add to that it was strange that Branch was allowed while Standard was not.

I didn’t have access to machines (or time) to test right then, but after getting back I tested and true enough you are not allowed to create a 64-bit host. The UI stops you. As you can see, this doesn’t stop BizTalk Server Standard from being installed on a 64-bit machine – it just doesn’t get the benefits of 64-bit processing.

image

I also found an “official” explanation to this here, which I’ve pasted below:

"We consider 64-bit support an Enterprise Edition level feature that a customer would only select if they require faster messaging/orchestration processing or the larger addressable virtual memory of 64-bit mode for large BizTalk message mapping or other memory intensive operations. Because the Standard Edition is designed for small-to-medium environments, it is licensed to only run on a single BizTalk server with a maximum of two CPUs, maximum of five "BizTalk Applications", and a single message box. 64-bit support for the Standard Edition seemed counter-intuitive from a technical and licensing perspective. If the deployment scenario requires 64-bit hardware then it certainly requires BizTalk Enterprise as well. Standard edition is for single box only installations. Enterprise is also required for multi box installs and for clustering."

Judging from the fact that 64-bit is now very much mainstream, especially on servers, I would expect to see this change in the upcoming releases of BizTalk Server.

Recent and upcoming BizTalk User Group Sweden events
11 November 09 10:01 PM | Johan Hedberg | 4 comment(s)

Some time ago, back on the 20th of November, Richard Seroter visited BizTalk User Group Sweden and talked about BizTalk, SOA and leveraging the cloud. His talks are now live on channel9, part 1 and part 2. A short blogpost explaining the talk is here.

It was great fun to have Richard visit, although some (most) of the laughter and clapping that your hear on the videos is really due to me making a pantomime Richard imitation outside of the frame of the video and should not be credited to him ;)

Getting the videos published wasn’t lightning fast due to some unfortunate circumstances and personnel changes. Hopefully that will be all ironed out by November 26th when Charles Young swings by us again, this time to talk about the Business Rules Framework. I’m sure it’ll be a classic. Take the chance to say “I was there”. There are still slots left. Sign up here.

Should you happen to pass by Sweden and have an interesting Connected Systems topic that you would like to talk about feel free to drop us a line.

Or as Richard commented his visit on his blog through this sentence taken totally out of it’s context ;) “If you get the chance to visit this user group as an attendee or speaker, don’t hesitate to do so.

color-drop[1]

Filed under: , ,
Cleaning up BizTalk database backups
10 November 09 09:39 PM | Johan Hedberg | with no comments

Everyone knows (read that as: should know ;) that enabling the BizTalk jobs “Backup BizTalk Server” and “DTA Purge and Archive” is a good thing. Even on simple test machines, and perhaps (preferably) even on your developer laptop. What happens some times though is that, when you end up using the dump-to-disk approach, you fill up your disks. This happens because by default the BizTalk Backup and DTA Purge and Archive jobs doesn’t clean house. In your production and staging environments the “IT guys” will usually have your back in this case and make sure that doesn’t happen. For those environment where that isn’t the case here’s an easy to use script provided by our IT guys to help keep things tidy. It uses the forfiles statement as the bulk of its logic.

@echo off
set BACKUP_PATH=%1
set RET_INTERVAL=%2
if "%BACKUP_PATH%"=="" exit 1
if "%RET_INTERVAL%"=="" exit 1
Forfiles /P %BACKUP_PATH% /S /M *.BAK /D -%RET_INTERVAL% /C "cmd /C Del @path"
exit %ERRORLEVEL%

Now all you need to do is to call this script from somewhere. A suggestion might be from a SQL job. This way you configure the backup and the cleanup of the backup files from a single location. Like this:

exec xp_cmdshell 'script.cmd C:\Backup 4'

script.cmd should be the full path to your script, while C:\Backup should be the full path to your backup directory. Remember to surround paths by “ should they contain spaces. The 4 in this case says that any files 4 days and older will be removed. Schedule as you see fit.

Preparing for PDC 09
09 November 09 11:39 PM | Johan Hedberg | 2 comment(s)

I’ll be there. I’m happy about it. The sessions looks promising, although I have to say that the functionality of the website as far as scheduling goes really blows. There it no way to visualize your schedule, and no way to export it to your outlook calendar or even to something like Excel. That I’ve found to this date.

There are three sessions awarded with the BizTalk keyword (listed in my order or interest):

Microsoft BizTalk Server Futures and Roadmap

Learn how BizTalk Server 2009 lets you focus on writing the code to do the hardcore business logic and let BizTalk take care of moving the data. Hear how your development skills with Windows Communication Foundation (WCF), and Windows Workflow Foundation (WF) work seamlessly with the powerful integration platform of BizTalk. Find out how BizTalk aligns with the Microsoft application server in the longer term.

Queuing and Publish/Subscribe in a Heterogeneous Environment

Queuing and publish/subscribe are common patterns for building loosely-coupled, distributed applications. Learn how to use Microsoft Windows Communication Foundation (WCF) the new Microsoft ASP.NET 4.0 routing service, the Microsoft .NET Service Bus, and Microsoft BizTalk Server to easily connect heterogeneous systems. We then introduce AMQP (the Advanced Message Queuing Protocol), an important new open standard for interoperable message-oriented middleware, which will reduce the friction in connecting heterogeneous clients. A real-world scenario shows AMQP in action, connecting WCF, Microsoft Excel, and Java-based clients.

Connecting Applications with the Microsoft BizTalk Enterprise Service Bus

See how the BizTalk Enterprise Service Bus (ESB) enables you to build services that can be quickly located and connected, whether they live behind the firewall or in the cloud, without creating a brittle point-to-point link. Learn how to dramatically improve the service lifecycle of development, testing, and deployment by using the powerful messaging, routing, and transformation capabilities of the BizTalk ESB in your solution today, and get a glimpse of future plans for BizTalk service bus/pub-sub pattern

The team talks about the upcomming BizTalk content at PDC09 here.

Filed under: , ,
Oh BizTalk, why dost thou mock me?
08 November 09 10:37 PM | Johan Hedberg | 1 comment(s)

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.

More Posts Next page »

This Blog

News

    Messenger

    Twitter Updates

      Follow me on twitter

      Visitors

      Feedburner Subscribers

      Locations of visitors to this page

      Disclaimer

      All material is provided AS IS voiding any thinkable or unthinkable effect it might have for any use whatsoever. There... is that clear enough ;)

      Pages

    Syndication