Wednesday, November 15, 2006

Writing to Eventlog while working with maps using Eventlog Functoid in Biztalk Server 2004


Writing to Eventlog while working with maps using Eventlog Functoid in Biztalk Server 2004

While testing our maps at times when it fails we feel that what could have went wrong and we cant trace it because we don’t know what the output of the functiods are. Normally in a single map we use normally 50-60 functiods.Were do we start debugging our Map. It’s tough when we are under pressure to deliver it on time to debug a map. But it’s a part of our job to make sure that our map is stable. I thought of this functiod while working on a project where in I wanted to see the output of a specific Scripting functiod.
So I just planned to have one which will write to Eventlog any output of data type string. So now what we need to do is just use this functiod to insert into Eventlog.This functiod will return the string after writing it to Eventlog. So just at an overhead of 1 functiod we can test our map to perfection.Just build the solution and drop theEventlogFunctiod.dll in
C:\Program Files\Microsoft BizTalk Server 2004\Developer Tools\Mapper Extensions
And  also GAC it. Then add it in the toolbox and use it in your maps.
Hope it helps you in your project.
The code is given below

using System;
using Microsoft.BizTalk.BaseFunctoids;
using System.Reflection;
using System.Xml;
using System.Diagnostics;
//Summary
//This Class will write an entry in event log.
//It will take up 1 parameter as input and will output the same parameter after writing it to eventlog
namespace EventlogFunctiods
{
 public class EventlogFunctoid: BaseFunctoid
 {
  public EventlogFunctoid()
  {
   this.ID = 6464;  
   SetName("EventLog");
   SetTooltip("Please pass only 1 parameter");
   SetDescription("This Functiod writes the specified parameter to Eventlog.It takes up only 1 paramter");  
   this.SetMinParams(1);
   this.SetMaxParams(1);
   SetExternalFunctionName(GetType().Assembly.FullName,
    "EventlogFunctiods.EventlogFunctoid", "EventlogFunc");
   this.Category = FunctoidCategory.String;
   this.OutputConnectionType = ConnectionType.AllExceptRecord;
   AddInputConnectionType(ConnectionType.AllExceptRecord);  
  }
  public string EventlogFunc(string param1)
  {
   System.Diagnostics.EventLog.WriteEntry("Eventlog-Functiod",param1);
   return param1;  
  }
 }
If you find it tough to implement....just download the solution which is available at
Any queries or bugs would be appreciated because “To err is human”.

Wednesday, May 3, 2006

Storing Usernames, Passwords in SSODB Database using MMC 3.0


Whenever we work on BizTalk projects we feel why there is no provision for App.Config file so that one can store Key/Value pairs in it. So to have a work around for it we save key/value pair in Btsntsvc.exe.config file.
It is one of the easiest work around.
1. But can you store sensitive data like your domain password in a  place which is visible and accessible to all.
2. Do you feel changing btsntsvc.exe.config file is right from developer point of view.
I do feel your answer is No…not at all. Well in such scenario SSODB comes in picture. The key/value pair is stored in encrypted format so nobody can access sensitive data. No btsntsvc.config file is involved in it. Single Sign-On database (SSODB) is a standard Database which gets installed while one installs BizTalk Server.
My Dummy Solution contains 3 projects.
1. SSODB Helper class to query SSODB.
2. MMC3.0 Snap-in for Administrators to add key/value pairs.
3. Windows Form to test the SSODB helper class.
We can user SSODB Helper class in our Orchestration to get any key/value pair. I won’t get into technical details of how to develop it. MMC 3.0 developments with C# is not officially supported by Microsoft. "Sample Snap In" development code can be downloaded from Microsoft site.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/managedMMC/html/a335f609-a929-449a-86f6-29ac7c227709.asp
I had a thread running regarding Developing "MMC 3.0 Snap IN" at
http://groups.google.com/group/microsoft.public.management.mmc/browse_thread/thread/88b4e3da49af3ceb/71f5ee87514f63ac?lnk=gst&q=mmc3.0&rnum=12&hl=en#71f5ee87514f63ac
 The Snap-In looks like the one below. One can create Application…which in turn contains Key/value pairs. SSODB stores in terms of Application Name-ConfigName-Key/value pairs. So one Application can contain more then one ConfigName which contains many key/value pairs. For simplicity I had only one ConfigName which contains many key/value pairs. So in my current solution I have no Provision for multiple ConfigNames.
SSO
One needs to first Add an Application. A new application with name “NewChild”. One needs to rename it to the Application Name one wants. Application Names are user friendly names…So you can name it as per your convenience. Then one can add key/value pair. It’s worthwhile to work with SSODB and its pretty challenging. Queries and Bugs are always welcomed.
Sample is available at.
http://www.codeplex.com/NishSSODB/Release/ProjectReleases.aspx?ReleaseId=4438
How to use the Sample
Open the solution
press F5
A new window pops up.
Press Button1.
A new application by the name "NISHILAPP7" is created in SSODB.
The Windows Form is just for you to understand what is SSODB.
I have just coded to create one Application in SSODB in that Form.
You can customize it as per your needs.
You can install the SnapIN. Through that SnapIn one can add Application,key value pair.
How to install SnapIn.....refer Sample SnapIN ..MSDN link above.
You can use SSODB helper class to get the value for specific keyname.

Friday, January 27, 2006

Output validation error: Root element is missing....Biztalk Map


Recently while  working on a map I constantly used to get this error
Error 3 Output validation error: Root element is missing
I thought that since I have not mapped few Destination fields it might be throwing such error.
I tried setting Output Validation False for the Map.
Still I was getting the same error.
The Map was a simple one to one link map.
I was confident that my input xml file was perfect and  I did confirm it by Validating it against the Input Schema again.
It got succeeded.No errors at all.
Now where could be the problem be.
So I just googled and got this link by Stephen.
http://geekswithblogs.net/sthomas/archive/2006/08/15/88094.aspx
And then I cross verified my Target namespace in the input Schema with the input xml file.
There was a blank space before and after the namespace in my Schema which was creating this problem for me.
Moral of the story:
" Validating the xml file against the Schema never assures that the two match each other".

Tuesday, November 22, 2005

Database Lookup Functiod[For Beginners only]


Working with BizTalk and don’t need to interact with SQL database…….nah…that’s not possible. I googled for database Lookup functiod but no link gave me a simple sample as to what this functiod does and other functiods which are linked to this Database Lookup Functiod. So I just thought to pen down few Standard database functiods available with BizTalk
First let’s start with.
Database lookup Functiod.
I created a table called “NishTable” with fields and values as below. DBFunctImage1
                                           Fig1

Then I create an Empty BizTalk Project with
1 Map and 2 Schemas.
Create the Schemas as shown in the Fig2.
Just drop in the Database Lookup Functiod on the Map as shown in Fig2.
DBFunctImage2
                                        Fig2

Let’s Configure this Database Lookup Functiod.
For this Sample I won’t pass any input …it would be harcoded.
Right click on the Functiod…properties…
1 parameter-Just type 2
2nd Parameter-Sql connection String.
3rd Parameter-Table name-NishTable (Created before)
4th Parameter-Column name.-EmpID
What these configured values means is
“Select _ from NishTable where EmpID=2”.See fig 3 for details.
DBFunctImage3
                                             Fig3
Now we need to fill in the blank space in the above sql query as to what should be selected. So we use value extractor functiod and configure it as soon in fig4.
EmpName is the field whose value I want…So I type “EmpName” as second parameter.
Mapping is simple 1 to 1 map.
DBFunctImage4
                                             Fig4
This way a Database Lookup functiod works. You can test your map.
Now what about error handling. If the sql connection is down?
So let’s use “Error Return functiod” here.
Just link the functiods as shown.
“Error Return functiod” requires only 1 parameter that should be the output of Database Lookup functiod.
Refer fig 5 for more details.
DBFunctImage5
                                          Fig 5
Just to test it I stopped my Sql server and I can see the output as below. DBFunctImage6
                                           Fig6
So this was Database lookup Functiod. We can use this instead of using a .net component inside map to get the values from database.