Tenalinaga's Blog

I am frog in a well. Every time I jump out of the well; I relialize I am in bigger well and eventually get bored which motivates me to get to next level.

Monthly Archives: September 2010

Error with ODBC Driver

GetBatchOfMessagesAndSubmit Error: Receive Port query processing failed: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

The adapter “ODBC” raised an error message. Details “Receive Port query processing failed: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ”

Resoultion: Remove user DSN user account and add it to System DSN.

Advertisements

Custom Pipeline Component To PreProcess XML (can be modified to add just AddNameSpace)

After Debatching there will times in which extracted nodes will not have name namespace. This will create problems in transformation shapes and message types not being matched. So this example shows custom component to preprocess xml nodes by adding namespace before it is split. Then you can use xml disassembler or ESBdispatcher disassembler components to split the envelope which will provide xsd schemas with namespaces.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Resources;
using System.Reflection;
//BizTalk Classes
using Microsoft.BizTalk.Message.Interop;
using Microsoft.BizTalk.Component.Interop;

namespace XXX.AddNameSpaceUpdateBatch
{
[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]
[ComponentCategory(CategoryTypes.CATID_Any)]
[System.Runtime.InteropServices.Guid(“9d182f63-7663-4c42-b9e0-31088e92d369”)]
public class CustomAddNameSpaceUpdateBatch : Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, Microsoft.BizTalk.Component.Interop.IBaseComponent, Microsoft.BizTalk.Component.Interop.IComponent, Microsoft.BizTalk.Component.Interop.IComponentUI
{

private string _NewNameSpace;
public string NewNameSpace
{
get { return _NewNameSpace; }
set { _NewNameSpace = value; }
}

#region IBaseComponent Members

public string Description
{
get
{
return (“Add NameSpace to XML”);
}
}

public string Name
{
get { return (“XmlUpdateRecordsStatusAddNameSpace”); }
}

public string Version
{
get { return (“1.0.0.0”); }
}

#endregion

#region IComponentUI Members

public IntPtr Icon
{
get { return new System.IntPtr(); }
}

public IEnumerator Validate(object projectSystem)
{
return null;
}

#endregion

#region IComponent Members
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
IBaseMessagePart bodyPart = pInMsg.BodyPart;
//StringBuilder outputMessageText = null;
string messageType = “”;
if (bodyPart != null)
{
Stream originalStream = bodyPart.GetOriginalDataStream();
if (originalStream != null)
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(originalStream);

StringWriter sw = new StringWriter();
XmlTextWriter tx = new XmlTextWriter(sw);
xdoc.WriteTo(tx);
string _strXdoc = sw.ToString();
System.Diagnostics.EventLog.WriteEntry(“”, _strXdoc);
_strXdoc = _strXdoc.Replace(“

“, “”);
_strXdoc = _strXdoc.Replace(“
“, “”);
System.Diagnostics.EventLog.WriteEntry(“”, _strXdoc);

byte[] outBytes = System.Text.Encoding.ASCII.GetBytes(_strXdoc);
MemoryStream memStream = new MemoryStream();
memStream.Write(outBytes, 0, outBytes.Length);
memStream.Position = 0;

bodyPart.Data = memStream;
pContext.ResourceTracker.AddResource(memStream);

}
}
messageType = “http://NameSpace#RootNode”;
string systemPropertiesNamespace = @”http://schemas.microsoft.com/BizTalk/2003/system-properties”;
pInMsg.Context.Promote(“MessageType”, systemPropertiesNamespace, messageType);

return pInMsg;
}

#endregion

#region IPersistPropertyBag Members

public void GetClassID(out Guid classID)
{
classID = new Guid(“b94e8347-9516-4cbb-8c8b-dcf0789008c2”);
}

public void InitNew()
{

}

public void Load(IPropertyBag propertyBag, int errorLog)
{
object val = null;

try
{
propertyBag.Read(“NewNameSpace”, out val, 0);
}
catch (Exception ex)
{
throw new ApplicationException(“Error reading propertybag: ” + ex.Message);
}
if (val != null)
_NewNameSpace = (string)val;
else
_NewNameSpace = “http://AnonymusURL”;

}

public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
{
object val = (object)_NewNameSpace;
propertyBag.Write(“NewNameSpace”, ref val);

}

#endregion
}
}

Looping in BizTalk Orchestration.

When we have message with recuring nodes inside orchestartion there are several ways to Debatch the message.

1) Envelope schema being my favourte

2) Looping using Xpath with in orchestration is also clean way. Good Sample in the link

3) We could also write a custom component that does debatching which is little involved.

We shall see how we deal with these three cases in this topic.

Hello Folks!

I realize what I know and understand is so small compared to what exists. I am passonate about technology and learning.

Microsoft BizTalk is primarly focus of my blog for now. Here I wish to document some Errors that trouble me and Examples I find intersting.

This is perfertly useless introduction, but that is yet for now.