Friday, 9 March 2012

Looping functoid in BizTalk map

Using Looping functoid in BizTalk Map:
1.      Create two schema, Order schema and MasterOrderSchema with below shown structure.
2.      OrderSchema will have order from multiple companies, using “LOOPING” functoid we will map it to MasterOrdeeShema.
3.      We will create a map to achieve  this, in this map we will use Looping functoid (Advanced Functoid Grp).

Order Schema


MasterOrderSchema


Map – OrderSchemaToMasterOrderSchema.btm



Now test the map created with input instance Order.xml file

<ns0:Order xmlns:ns0="http://LoopinFunctoidSoln.OrderSchema">
  <ABCCompany>
    <ID>11</ID>
    <ItemName>ItemName_0</ItemName>
    <Qty>10</Qty>
  </ABCCompany>
  <PQRCompany>
    <ID>1</ID>
    <ItemName>ItemName_1</ItemName>
    <Qty>2</Qty>
  </PQRCompany>
  <XYZCompany>
    <ID>2</ID>
    <ItemName>ItemName_2</ItemName>
    <Qty>5</Qty>
  </XYZCompany>
</ns0:Order>

And we will get output as MasterOrder.xml file as shown below.

<ns0:MasterOrder xmlns:ns0="http://LoopinFunctoidSoln.OrderSchema">
<Company>
  <ID>11</ID>
  <ItemName>ItemName_0</ItemName>
  <Qty>10</Qty>
  </Company>
<Company>
  <ID>1</ID>
  <ItemName>ItemName_1</ItemName>
  <Qty>2</Qty>
  </Company>
 <Company>
  <ID>2</ID>
  <ItemName>ItemName_2</ItemName>
  <Qty>5</Qty>
  </Company>
  </ns0:MasterOrder>
 

Wednesday, 7 March 2012

Creating Envelope Schema in BizTalk

1.      Create two schema , contect and PhoneBook(Enevelope Schema)
2.      Here we create a contact schema and which we will use in our envelope schema phonebook.
3.      Set PhoneBook envelope schema poperty to “Yes”.Import Contact schema to PhoneBook schema using “Imports ….Ellipse icon”.
4.      CInsert a new child record inside the PhoneBook node and name it as Contact.
5.      Select contact node Data Type property to  “ns0:Contact (Reference)”.


Developin custom Functoid in BizTalk

1) Fine, create a new project its type is class library and name it CustomFunctoid.
2) Add a reference of Microsoft.BizTalk.BaseFunctoids you can find it here :X:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Microsoft.BizTalk.BaseFunctoids.dll (where X the drive that holds the installation of BizTalk server 2006)
3) let you class implement from BaseFunctoidpublic class Percentage : BaseFunctoid
4) let the constructor override the basepublic Percentage(): base()
5) write the following line of code in the construction :
this.ID = 3003;
SetupResourceAssembl("CustomFunctoid.CustomFunctoidResource", System.Reflection.Assembly.GetExecutingAssembly());
SetName("PERCENTAGE_NAME");
SetTooltip("PERCENTAGE_TOOLTIP");
SetDescription("PERCENTAGE_DESCRIPTION");
SetBitmap("PERCENTAGE_BITMAP");
this.SetMinParams(2);
this.SetMaxParams(2);
SetExternalFunctionName(GetType().Assembly.FullName, "CustomFunctoid.Percentage", "CalculatePercentage");
this.Category = FunctoidCategory.Math;
AddInputConnectionType(ConnectionType.AllExceptRecord);
AddInputConnectionType(ConnectionType.AllExceptRecord);
this.OutputConnectionType = ConnectionType.AllExceptRecord;

6)Now create the function that will calculate the percentage which is :

public float CalculatePercentage(float x, float y)
{
float c = float.MinValue;
c = (x / y) * 100;
return c;
}

7) Create a Strong key , and Assign it to your class library


8) Build the Class Library and copy the DLL to : X:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Mapper Extensions (where X is the drive that holds the installation of BizTalk Server 2006)
9) Add this dll it to the GAC ( open the Visual Studio 2005 Command Prompt and type GACUTIL –i X:\CustomFunctoid.dll)


10) Add it to the ToolBox in Visual Studio 2005 (right click on the ToolBox, choose Add/Remove items, click the Functoids tab and browse to the Customfunctoid.dll file and make sure it’s checked.

Reading schema node value

Following example show, how to read schema node value:

strAction = System.Convert.ToString(xpath(msg_StudAcadsReq,"string(
/*[local-name()='getStudentAcademicRequest' and amespace-uri()='http://schemas.careered.com/student']
/*[local-name()='Header' and namespace-uri()='http://schemas.careered.com/student']
/*[local-name()='Action' and namespace-uri()='http://schemas.careered.com/student']
)"));


strSSID = System.Convert.ToString(xpath(msg_StudAcadsReq,"string(
/*[local-name()='getStudentAcademicRequest' and namespace-uri()='http://schemas.careered.com/student']
/*[local-name()='Header' and namespace-uri()='http://schemas.careered.com/student']
/*[local-name()='SourceSystemId' and namespace-uri()='http://schemas.careered.com/student']
)"));