Pages

Use Fiddler with BizTalk to monitor Incoming/Outgoing Traffic

Friday, June 7, 2013

Using Fiddler to debug BizTalk messages?

When using HTTP, SOAP or WCF send ports it can be incredibly useful to view the content of messages that are sent on the wire. This allows you to inspect the headers (SOAP or HTTP). Fiddler is a simple but fantastic tool to allow you to do this.

By default, Fiddler will not trace any messages sent to endpoints by BizTalk as it does not use WinInet. However, BizTalk send ports can be configured to use a proxy allowing Fiddler to intercept them. On the Send Port tick the Use Proxy checkbox and set the Server to 127.0.0.1 and the port to 8888. For dynamic ports, set the following properties (as applicable to the adapter being used)

// Debug via fiddler
msgSendRequest(SOAP.UseProxy) = true;
msgSendRequest(SOAP.ProxyAddress) = "127.0.0.1";
msgSendRequest(SOAP.ProxyPort) = 8888;



Note that this needs to be removed when Fiddler is not running since traffic directed to the proxy will not be received by anything.
Read more ...

Fix Huge Maps in BizTalk - change default behavior - Undocumented Fix

Wednesday, June 5, 2013
post by Brett
I have been working with several industry standard Xml schema definitions, specifically those defined by the UBL standard by OASIS (www.oasis-open.org).  This organisation has a worthwhile, yet lofty, goal of defining a set of document standards that will cover the majority of communication needs for B2B.
The result of trying to be all things to all men is that the schemas defined are big.  Like really, REALLY big, with a set of included schema file that run about 8-10 deep.
The problem with this, in the BizTalk world, is when you either generate an instance document from the schema, or attempt to map a document to a UBL schema document using the BizTalk Mapper.  Due to the way the BizTalk handles default nodes, you end up with all default values being output into the destination document.
A quick, undocumented fix for this is to change the GenerateDefaultFixedNodes setting in the BizTalk Map.  Where is this setting, you ask?
Open the .btm file using the “XML Editor”, rather than the default “BizTalk Mapper” (i.e. right-click, choose “Open With…”, then XML Editor).  The root node of the map document is called “mapsource”, one of the attributes is called “GenerateDefaultFixedNodes”.  Change this from “Yes” to “No”, save and close, and you’re done.
This undocumented trick brought one of our generated XSLT transforms down from a slightly ridiculous 50 Mb to an easily handled 11 Kb, and the transform execution time from 20 seconds down to about the 50 millisecond mark (on a virtual machine)
Read more ...

Biz Talk : How To : Throw Custom Exception in Map

Monday, June 3, 2013
post by Brett

I have run into an instance where I need to terminate and raise an exception from within an XSLT template, based on values (or lack thereof) within the source document.  The XSLT transform is running within a BizTalk map.

The secret is the following little-known XSLT construct, which can be conditionally called at any point in the transform:

<xsl:message terminate="yes">Custom error text</xsl:message>
This will cause the XSLT engine to stop processing immediately, and raise an exception.   This exception, including the custom error text contained within the message segment, can be caught in the BizTalk Orchestration engine by explicitly catching an exception of type 

Microsoft.XLANGS.BaseTypes.TransformationFailureException.
Read more ...

Run .bat and .ps cmd files from Visual Studio 2010 2008

Monday, June 3, 2013
post by Rick Glos:

Visual Studio 2010 | 2012

You can use this technique to run windows command files with the .bat and .cmd extensions.
Just as previously, we need to create at least one, and optionally two, external tools.
One that terminates the window after executing.
Here’s the values for you to copy+paste and screenshot.
FieldValue
TitleRun With Cmd
Command%ComSpec%
Arguments/C $(ItemPath)
Initial Directory$(ItemDir)
screenshot
One that leaves the command window open after executing.  Useful if you didn’t put a ‘pause’ in your command file or if you want to leave the cmd window open for additional commands.
FieldValue
TitleRun With Cmd and Remain
Command%ComSpec%
Arguments/K $(ItemPath)
Initial Directory$(ItemDir)
screenshot
Now we should see our new external tools available on the Tools menu.
image
However, we’d like to right-click on the file and run the cmd file via Solution Explorer like so:
image
Customizing this context menu in Visual Studio 2010 is abit different from context menu customization in VS2005/2008.
Click Tools –> Customize… to launch the Customize Dialog.
From that dialog we want to select the ‘Context menu’ radio option and the ‘Project and Solution Context Menus | Item’ from the drop down.  I’m going to put the two commands right under ‘Open With…’.  You can certainly do whatever you wish.  Start this process by clicking ‘Add Command’ button on the same dialog.
So here’s a screenshot with that above paragraph in a picture instead of words:
image
When we click ‘Add Command’, the Add Command Dialog will open.  Select ‘Tools’ from the Catgories list box on the left and find your external command from the command list box on the right.  Your command will be named something like ‘External Command {Number}’ where {Number} is the number in your list from your External Tools dialog.
image
Clear as mud?  I’m going to use this to make sure I add External Command 3 and External Command 4 to the context menu.
image
Now the ‘Project and Solution Context Menus | Item’ context menu should look like this in the Customize Dialog.
image 
Close that dialog and check out your new menu items by right clicking on a file in Solution explorer.  You should see your new external commands.
image
For extra credit, you can go back into the Customize dialog and move your commands around into spot your like and alos create a Group around them.
image

The finished product looks like this.
image

Visual Studio 2005 | 2008

his will take you a few minutes to setup but once your done, it will save you countless minutes.
It's not unusual to have scripts in your project or solution that automate tasks.  Everything from executing a powershell script, moving files around, or some other custom automation tool you may have written.
The default for double-clicking a cmd file in Visual Studio is for it to open the script for editing.
image
But what if you want to execute it?
One way is to right click the folder above the file, choose 'Open Folder in Windows Explorer', wait for that window to open, find the file with your eyes again, and double-click to execute it.
I tried using the 'Open With...' menu item and adding cmd but it doesn't allow you to pass in the file.
image
So what you end up with is an empty cmd prompt window that hasn't executed the script you thought it would.
Ok great so how did you do it?
On the tools menu you can add external tools and add arguments.  So Tools -> External Tools and a window will open that allows you to run with cmd and also pass in the initial directory as well as some additional arguments.
I created two:
One that terminates the window after executing
TitleRun With Cmd
CommandC:\Windows\System32\cmd.exe
Arguments/C $(ItemPath)
Initial directory$(ItemDir)
image
One that remains after executing
TitleRun With Cmd and Remain
CommandC:\Windows\System32\cmd.exe
Arguments/K $(ItemPath)
Initial directory$(ItemDir)
image
So now you can select the file in solution explorer, then select Tools -> Run With Cmd.
You could go one step further and add it to the context menu.
There's many ways to get into menu customize mode, one way is to choose View -> Toolbars -> Customize.  Make sure to select the 'Context Menus' toolbar and you'll notice a toolbar appear in your menu when you're in customize mode.
image
This next part is tricky.  Leave the customize dialog open - it's semi model, if you close it, you're out of edit mode.  Click Tools -> and you'll see you're new command listed something like 'External Command 3', you'll have to remember which ones you created (or yes you could go and customize that text as well).
Hold down control and left click (we want to copy this to the context menu not move it), slide your pointer over the 'Project and Solution Context Menus' menu item in the context menu toolbar, then down to 'Item', and drop it in there wherever you like.
image
Close the customize dialog.
Now you can right-click on a cmd file in Solution Explorer and select either 'Run With Cmd' or 'Run With Cmd and Remain'.
image
Read more ...