2014 m. sausio 21 d., antradienis

Best Tool for Productivity Improvement

Simple, yet powerful way to improve your own productivity:
Found this in the Scott Bercun's book "The Year Without Pants". While this is simple and old idea, but it does work.
Usually i find myself in working on some HUGE problems involving HUGE changes and HUGE commits after all. In some cases I'm finding myself lost in what i am trying to do at the moment. Other times while writing commit message i find that there are so many things done during this single huge thing. And sometimes you see that after whole day of refactoring you can commit only bunch of small cosmetic fixes.
At the moment I am trying to use my knowledge gained from this book:

  1. Think about what few next steps I should do. 
  2. Write them down to the list (other idea from Berkun's book). 
  3. Split into smaller until you know how long it will take to do it. 
  4. Start Working.
  5. Reorder the list as soon as something changes
At the moment it is quite hard to achieve good concentration, because a lot of distractions there are around us. Colleagues, skype, facebook, news, food, coffee & etc. But, when I have clear job list it becomes much more easier to keep up the performance.


2012 m. gruodžio 22 d., šeštadienis

BizTalk Goes to the Cloud

As far as I have been concerned - Microsoft continues to improve BizTalk and includes it in its cloud stack. That is a greate news for BizTalk developers, because there were some rumors from my local Microsoft MVP's that there will be no need for BizTalk in the cloud. They've said: start learning to do something other than BT :)

This presentation first slides provides most interesting keypoints about Microsoft's strategy what makes me sleep better:)

2011 m. gruodžio 13 d., antradienis

Pass port as a parameter - What a hell?

"Why on Earth would you need to pass a port as a parameter" one may think. But one may be wrong :)

I have faced some interesting situation when I've decided that passing port as a parameter is much more easier than using dynamic port.

The solution had to cover two totaly the same web services from two different banks. It is really nice, when the whole country has standarts to all their banks (see http://www.fkl.fi). The problem is when you have to use different authentication parameters inside WCF-Custom port, while underlying service remains the same. There are a lot of tricky adapter settings which sometimes should be changed, so I've came up with decision, that it is more conveient to have two configurable ports on the administration console, than trying to cofigure adapter settings on the dynamic send port.

Here is the main orchestration, which have real ports (Port_A and Port_B), which are cofigured using BizTalk Administration Console
Within main orchestration there are logic which decides which port to use. All the buisness logic goes to second orchestration, which is called from the first one. 

As you can see, second orchestration have three parameters: port, input message and output message. Output message parameter should be marked as "Out":
Of cource, the port parameter type should match port type from the main orchestration, and you should pay attetion that communication direction also can be changed from the properties window.

 Below you can see how both of call orchestration shapes are configured inside the main orchestration. Only thing which differs is port configuration.

Remove DTD declaration. Part II

In previous post there was method which removed DTD declaration from XmlDocument object. It is simple and nice solution unless there are a lot of big documents to process. XmlDocument class takes a lot of memory - usually about 8-10 times more than actual xml file. So, if you have 100 M xml file, you have up to 1G of memory used by XmlDocument object. I had to find another solution to remove DTD from the document.
I have asked for help of my collegue - I knew he was really great regular expression specialist, and he definately can help me. He came out with one simple method, which finds and removes everything what is between "" from the xml file (DECLARATION and comments). And this is done using String object and regex class, instead of heavy XmlDocument object.

Here is the code:
static public string RemoveDeclarations(String input)
                System.Text.RegularExpressions.Regex objRegExp = new System.Text.RegularExpressions.Regex("<![^>]+>");
                String input = objRegExp.Replace(input, String.Empty);
            catch { }
            return input;

Regular expression meaning:

[^>] - any count of any symbols except >;
+> - string should end with >;

All the character sequesces matching this criteria are replaced with empty strings. Thats it!

I've added try... catch block, in order to avoid suspending messages because of this method - if it fails, it returns unchanged string. This is not for every case - sometimes it is better to know where the problem is comming from.

2011 m. spalio 26 d., trečiadienis

Exception: (503) Bad Gateway before transformation

There was one project, with large numbers of messages going through the biztalk server (about 30 k messages per day). During testing stage everything lookded fine, but after production deployment there was some kind of  exceptions occouring on random files:
Exception: (503) Bad Gateway
What bothered mostly - after resuming stopped instances all the instances completed their job successfully.
Usually this exception occoured within transform shape, which made me very suspicious - why does transform shape need a gateway? After looking inside the files transfered, I've found DTD declaration within each file, which made me suspicious.
I've wrote small helper method, which removes DOCTYPE declaration from the Xml file:
public static XmlDocument RemoveDTDReference(XmlDocument xmlDocument)
                XmlDocumentType XDType = xmlDocument.DocumentType;
            catch { }
            return xmlDocument;
By using simple costruct shape expression, I've created new message before the transform:
ProductNoDTD = HelperClass.MessageReceiver.RemoveDTDReference(Product);
Thats it!

2011 m. spalio 24 d., pirmadienis

BTS Deployment Error: Access denied

There was really interesting error during pipeline project deployment into my BizTalk 2010 development machine. I've spent around half day on this error:
Error 64 Access to the path 'C:\Users\vytautas.dagilis\AppData\Local\Temp\BT\PID4424\BizTalkAssembly\57ee88747849cdd72cd21fa0abb59062\Project.dll' is denied.
Nothing did help: starting or restarting pc, moving or removing file & etc. I was looking for a process which could be using this - killed almost everything what was possible! Ain't no luck. There was few suggestions on the forums - kill indexing service (cisvc.exe). Again - nothing.

Only one thing which fixed things was found in the BizTalk gurus forum:

After adding two lines to AssdemblyInfo.cs file of this project solved all the problems:
[assembly: AssemblyInformationalVersion("")] [assembly: Microsoft.XLANGs.BaseTypes.BizTalkAssembly(typeof(Microsoft.BizTalk.XLANGs.BTXEngine.BTXService))]
It is pretty strange, when assembly version could cause file system access issues...

2011 m. spalio 18 d., antradienis

Simple UnitTest for BizTalk Map

Unit testing on BizTalk applications is pretty much hard task. All artifacts are different, and not easily executed from other code. Within this post I will introduce you to possibility to test BizTalk maps. In most cases there are a lot of problems if you want to test the connectivity, or the integration with another system. You have to count on your generated testing materials, which usually are not the same as found on the production.
There is one more question about map testing - is it usefull? I believe - YES, but not allways. When you reach some level of complexity and there can be at least some cahanges within map - it is better to have unit tests prepared. For small and simple maps it is unnecessary work. But for big ones, especially with a lot of nested loops - you should have some ways to check what your cahnges are effecting.
BizTalk 2010 already has some generators for unit test. You have to open your solution, then go to Visual Studio 2010 top meniu -> New Test...

Select "Unit Test Wizard" and you can choose either to create new test project or to add test files to the existing ones (using "Add to Test Project" drop down meniu).
In the "Create Unit Tests" dialog you should choose what classes and what method check you want to add to your unit test. In this case I am checking only map class, and press OK.
After pressing OK, wizard will automatically generate new project inside your solution, add all the required references and generate simple unit test cases for selected classes:
As we see the main line in all tests si map object initialization:

Map1 target = new Map1();

So, the target variable will hold our map, and it can be used to transform required input and output xml files. Here is some code from other map unit test, which is counting few tags from the new document and makes the decision if the map works correctly.

XDocument inputXml = TestingHelperComponents.OpenXmlFile("Transactions.xml");
StringWriter writer = new StringWriter();
 XmlDocument xmlDocument = new XmlDocument();

 target.Transform.Transform(xmlDocument, null, writer);

XDocument outputXml = XDocument.Parse(writer.ToString());

string temp = string.Empty;

int inCount = inputXml.Descendants("Transactions").Count();
int outCount = outputXml.Descendants("Transactions").Count();

Assert.IsTrue(inCount &gt; 0 &amp;&amp; outCount == 0, "Transactions tag count: inCount: " + inCount + " OutCount: " + outCount);

As you see, I am checking only some tag occourence after transformation. This maybe more tedious task, than simple string comparison, but I believe it is more stable - after making some minor changes inside map, there can be cahnges inside the output, which have no effect on the result (from information point of view).

I believe it would be good to make xml comparison method, which could compare inner xml data, regardless to formating, whitespaces, empty or null tags.

In the future I hope to try BizUnit or NUnit for testing BizTalk Solutions.