BizUnit Extensions – Suggestions invited

BizUnit Extensions – Suggestions invited

Okay, so thanks to everyone who has downloaded the RC1 bits of the extensions library. It seems to be working fine and i havent recieved word of any problems (except for one small bug in the string formatter step which will be fixed in the next update. We’ve got a list of things we want to work on to make the framework more of a proper product and make it really tester friendly and we’d like to invite feedback via email and on the discussion forum at http://www.codeplex.com/bizunitextensions. Let us know what you think.

Right now its rather developer focussed and involves lots of code. Do you like it the way it is or should we aim to put in some fancy GUI? what other steps do you think are missing that would be valuable for us to add in? how about steps you might have written that could be added in to the main code base?

As for those of you who arent using this tool, what are you using to test your Biztalk projects? I’ve heard that lots of folk have just rolled their own custom framework steps based on NUnit and most do lots of manual testing. Is that really sustainable? what are the pain points you are facing especially when using Biztalk ? (Would also be interesting to know what other products such as TIBCO, webMethods etc provide in the way of testing) Perhaps we should open up some discussion on approaches to testing and what works and what doesnt? Integration testing is definitely one of the areas where there is little in the way of best practice published and available.

BizUnit Extensions – Suggestions invited

BizUnit Extensions – Suggestions invited

Okay, so thanks to everyone who has downloaded the RC1 bits of the extensions library. It seems to be working fine and i havent recieved word of any problems (except for one small bug in the string formatter step which will be fixed in the next update. We’ve got a list of things we want to work on to make the framework more of a proper product and make it really tester friendly and we’d like to invite feedback via email and on the discussion forum at http://www.codeplex.com/bizunitextensions. Let us know what you think.

Right now its rather developer focussed and involves lots of code. Do you like it the way it is or should we aim to put in some fancy GUI? what other steps do you think are missing that would be valuable for us to add in? how about steps you might have written that could be added in to the main code base?

As for those of you who arent using this tool, what are you using to test your Biztalk projects? I’ve heard that lots of folk have just rolled their own custom framework steps based on NUnit and most do lots of manual testing. Is that really sustainable? what are the pain points you are facing especially when using Biztalk ? (Would also be interesting to know what other products such as TIBCO, webMethods etc provide in the way of testing) Perhaps we should open up some discussion on approaches to testing and what works and what doesnt? Integration testing is definitely one of the areas where there is little in the way of best practice published and available.

Calling Web Service from BizTalk 2006 in a Messaging only Scenario (aka Content based Routing)

In this article I’ll explain how you can call a Web Service which requires multiple arguments using a Custom pipeline and a custom pipeline component in a messaging-only scenario without using any Orchestration.

 

Normally, when there is a requirement to call a web service from BizTalk, people tend to take the easy route of calling it via an Orchestration. When we do a web reference inside the orchestration, Orchestration does quite a lot of work for us. It creates all the required schemas, it creates all the required multipart messages, which will be passed to the web service as argument. It makes our life easier. But I guess like me, some of you out there might need to call the web service without using Orchestration. As shown in the above figure. I’ve one request-response HTTP receive port, and one Solicit response SOAP send port, through this I’m going to call a web service, which expects multiple argument (including one complex type) and return the result back to the caller (HTTP Response). Here are the steps: The attached sample file contains all the required file, I’m just going to explain the key factors in this article.

1. Web Service Definition:

[WebMethod]
public Person GetPersonInfo(Person person, string firstName, string secondName) {
//Some processing
return person;
}

2. Create a general custom pipeline component to construct the multipart message required for the Web Service call 

At run time SOAP Adapter in the send port will map the Biztalk multipart IBaseMessage to the Web Service argument based on the partName of IBaseMessage and argument names of the Webservice. The key factor is how we are going to construct the multipart message in the format required by the SOAP Adapter to make the WebService call. In my previous article I explained how you can easily generate the required IBaseMessage with help of MIME message and MIME Decoder component. But when it comes to reality we don’t want to get into another data format like MIME. So, in this article we are going to create custom pipeline component which will construct the correct IBaseMessage required by the SOAP adapter based on the input message and some pipeline design time properties (for more detail on design time properties see my white paper ) .

The custom pipeline component we are going to use has 2 design time properties FirstName and SecondName, which will be passed as parameters to the web service (See webservice definition from Step 1). We’ll pass the first webservice argument “Person” as the incoming message via HTTP receive port. The figure below show the custom design time properties configuration window within Biztalk Admin console. 

The code below is the snippet from the custom pipeline component (two important methods Execute and CreateMessage). The Execute method below without the first line of code will be equivalent to a PassThru pipeline component with default Biztalk IBaseMessage. 

#############################################################

public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
{
IBaseMessage msg = CreateMessage(inmsg.BodyPart.GetOriginalDataStream(), pc.GetMessageFactory(),inmsg.Context);
return msg;
}

#############################################################

IBaseMessage CreateMessage(Stream s, IBaseMessageFactory msgFactory, IBaseMessageContext context)
{
IBaseMessage msg = msgFactory.CreateMessage();
IBaseMessagePart part = msgFactory.CreateMessagePart();
part.Data = s;

msg.AddPart(“Person“, part, true);
msg.Context = context;

//1st Part
IBaseMessagePart partFirstName = msgFactory.CreateMessagePart();
byte[] firstPart = System.Text.Encoding.UTF8.GetBytes(string.Format(“<string>{0}</string>“, _firstName));
partFirstName.Data = new MemoryStream(firstPart);
partFirstName.Charset = “utf-8”
partFirstName.ContentType = “text/xml”
msg.AddPart(“firstName“, partFirstName, false);

//2nd Part
IBaseMessagePart partSecondName = msgFactory.CreateMessagePart();
byte[] secondPart = System.Text.Encoding.UTF8.GetBytes(string.Format(“<string>{0}</string>”, _secondName));
partSecondName.Data = new MemoryStream(secondPart);
partSecondName.Charset = “utf-8”
partSecondName.ContentType = “text/xml”
msg.AddPart(“secondName“, partSecondName, false);
return msg;
}

#############################################################

Our user defined function CreateMessage will create the required BizTalk IBaseMessage as shown in the below figure

In the above code snippet, the important things to note are highlighted in RED. The incoming message (“Person”) will go as the first part (BodyPart) of the IBaseMessage with the name “Person”, and then we added two more addional parts “firstName” and “secondName” to the IBaseMessage with correct partNames inline with the web service arguments. The other important thing to note is how the basic data types gets serialized. In our example we got “<string>{0}</string>” as value for firstName and secondName, because they are of type string. If for example you got int as your argument then you need to create the part in the format <int>5</int>.

NOTE: See the web service signature defined in Step 1 for comparison

3. Create a Custom Receive Pipeline using the custom pipeline component

Create a new Biztalk Receive Pipeline and place the custom pipeline component we created in the “Decode” stage of the pipeline.

4. Configure the ports

As shown in our design diagram at the beginning we need 2 ports to send and receive the message, the attached sample file got a binding file, this section is just for explanation, doesn’t explain in detail how to configure the ports. Make sure the URL are correct, both on Receive and Send side after importing the binding. You need to configure IIS as well to receive messages via HTTP, follow the link to configure IIS for HTTP receive  http://msdn2.microsoft.com/en-us/library/aa559072.aspx.

Two-Way HTTP Receive Port:

Solicit-Response SOAP Send Port:

We used the .NET Proxy class on our SOAP port to make the call.

Filter Condition on the Send Port

5. Post a Message.

I used WFetch to post the message to BizTalk. You can see on the result pane the request message is posted and you got the response back from the web service synchronously on a two way connection.

Troubleshooting:

Some of the common exceptions you’ll see while calling a webservice via SOAP adapter is shown below (from HAT and eventviewer)

1. “Failed to retrieve the message part for parameter “firstName”.

2. “Failed to serialize the message part “firstName” into the type “String” using namespace “”. Please ensure that the message part stream is created properly.”

The reason for the first error message is due to wrongly named IBaseMessage partName. Read Section 2 carefully to overcome this error.

The reason for the second error message is mainly due to some problem with serializing the IBaseMessage parts to the correct web service arguments. Best approach to overcome this error will be to build a .net console/windows application, add a web reference to the webservice and try to serialize each argument to the corresponding type. For example for this example you can try the following

FileStream fs = new FileStream(@”C:\Documents and Settings\SaravanaK\Desktop\FailedMessages\_Person.out“,FileMode.Open,FileAccess.Read);
XmlSerializer serialise = new XmlSerializer(typeof(LH.WebReference.Person));
LH.WebReference.Person per = (LH.WebReference.Person)serialise.Deserialize(fs);
fs.Close();

fs = new FileStream(@”C:\Documents and Settings\SaravanaK\Desktop\FailedMessages\_secondName.out“,FileMode.Open,FileAccess.Read);
serialise = new XmlSerializer(typeof(string));
string s2 = (string)serialise.Deserialize(fs);
fs.Close();

The files “_Person.out” and “_secondName.out” are saved from HAT tool. See the exception detail and fix the issue, it will be some namespace issue or data issue.

DOWNLOAD SAMPLE

Read the readme.txt file inside to configure it. Will take approximately 5-20 minutes based on your BizTalk knowledge level.

Related Post

In one of my previous post I explained how to call a web service that has more than one argument using a MIME message in a Content based routing(messaging only) scenario.

Nandri!

Saravana Kumar

PipelineTesting Library v1.0.1.0 Released

I’ve just uploaded an
updated version of my PipelineTesting library
for BizTalk Server 2006. This version fixes an issue that Gregory
Van de Wiele
pointed to me a couple of weeks ago. Thanks Gregory!

The issue was that when I added Transaction support to the pipeline library, I didn’t
provide a way to control the transaction lifetime, or worse, the transaction end result.
What ended up happening was that if you called EnableTransactions() on the pipeline,
the transaction was created on demand when one component in the pipeline called IPipelineContextEx.GetTransaction().
However, nowhere did I explicitly release the transaction nor called Commit()
or Rollback() on it causing fairly ugly issues because the transaction release
was left to the GC.

Fixing this issue did imply I had to make a breaking change in the API, but hopefully
not one too bad. I changed the EnableTransactions() method in the pipeline classes
to return a TransactionControl object that you could use to control transaction lifetime
and result. Basically, this one works pretty much like the TransactionScope class
in System.Transactions: You wrap it in a using() declaration and if you want to commit,
you cal SetComplete() on it just before disposing it. Here’s an example of using the
pipeline with the transaction support enabled:

[Test]

public void CanCreateTransaction()

{

   SendPipelineWrapper pipeline =

      PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

   using ( TransactionControl control = pipeline.EnableTransactions() )

   {

      // Create the input message to pass through the pipeline

      Stream stream = DocLoader.LoadStream(“SampleDocument.xml”);

      IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

      // Add the necessary schemas to the pipeline, so that

      // disassembling works

      pipeline.AddDocSpec(typeof(Schema1_NPP));

      pipeline.AddDocSpec(typeof(Schema2_WPP));

      MessageCollection inputMessages = new MessageCollection();

      inputMessages.Add(inputMessage);

      // Execute the pipeline, and check the output

      IBaseMessage outputMessage = pipeline.Execute(inputMessages);

      Assert.IsNotNull(outputMessage);

      control.SetComplete();

   }

}

Enjoy.

Technorati
tags: BizTalk
Server
, BTS, Unit
Testing
I’ve added an IE7 Search Provider to my Blog

I’ve added an IE7 Search Provider to my Blog

It’s all pretty easy actually – if you have IE7 look in the drop down list of search
providers (top RHS) and you’ll see me smile_regular 

Dont know whether you’ll use it – but it saves me all the time when I’m out on site
and “I know I put that somewhere…..” thought comes into my head.

The way to set your own provider up:

  1. Create an XML Sample Provider file – from here 

  2. Upload the file to your blog somewhere – let’s say the root.

  3. Add the line to the top of the page
    <link rel=”search” title=”<your title>” href=”<url
    to searchProvider.xml>” type=”application/opensearchdescription+xml” />

  4. Save all and you get a nice little drop down entry like mine!

    Enjoy!

MOSS 2007 CSS Styles explained and Visualised…

Here’s a great page I came across maintained by Heather
Solomon
doing some great work around showing us what the styles look like and
do in MOSS – all ready for customisation Doctor….

http://www.heathersolomon.com/content/sp07cssreference.htm

 

Snippet…..

Table of Contents
  1. Global Links (Sign In/Welcome, My
    Links, etc.)

  2. Search

  3. Top Horizontal Navigation Bar

  4. Site Actions Menu

  5. Left Vertical Navigation Bar

  6. Quick Launch Picker (Date Picker)

  7. Title Area

  8. Content Area

    1. General

    2. Breadcrumbs

    3. Edit Console

    4. Mini Console

    5. Web Parts

    6. Menu Toolbar

    7. Toolbar

    8. Calendar
  9. Search Center

  10. Site Directory
BizTalk 2006: Tool to add application and references from the command line

BizTalk 2006: Tool to add application and references from the command line

BizTalk Server 2006 allows us to use the concept of Application to logically organize the artifacts in our solutions, such as orchestrations, schemas, send and receive ports, etc. Further, you can add references from one application to other applications, which allows you – for example – to bind an orchestration logical receive port to a receive port defined in some other (referenced) application, or create a Send Port filter using a property defined in a Property Schema included in other application.
You can use the Administration Console to add these references manually, by simply selecting an Application’s properties and the “References” tab.


I am a huge fan of scripts and automation, so I quickly developed a command line tool to help me a) create applications and b) add references from one application to other application, which I use further automate my deployments, which sometimes are not easily done with MSI’s.


Sample usage is:


BizAppManage -AddApp nameOfAppToCreate nameOfAppToReference1 nameOfAppToReference2 nameOfAppToReference3
BizAppManage -AddRef nameOfExistingApp nameOfAppToReference1 nameOfAppToReference2


I’ve used Carlos Medina’s BtsHelper class to avoid hard-wiring the BizTalk connection string.