Tuesday 29 January 2013

Customize Biztalk Service URL when Orchestration expose as webservice

Customize Biztalk Service URL when Orchestration expose as webservice

Step 1: Change Svc filename to new serviceName.











Step 2: Change URL in ReceiveLocation Properties at Biztalk Admin  Console.



Step 3 : Changes in ServiceDescription.xml , available at
C:\inetpub\wwwroot\WebsiteFolder\App_Data

ServiceName and PortType Name

Example :

<?xml version="1.0" encoding="utf-16"?>
<BtsServiceDescription xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Company.Demo.Schemas" TargetNamespace="http://tempuri.org/" xmlns="http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF/Publishing">
  <Description />
  <MessageType Name="Company.Demo.Schemas.Schema1#Schema1" FileName=".\Company.Demo.Schemas.Schema1.xsd" AssemblyLocation="C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Company.Demo.Schemas\v4.0_1.0.0.0__3b0fe90ef71d5ac4\Company.Demo.Schemas.dll" AssemblyName="Company.Demo.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b0fe90ef71d5ac4" TypeName="Company.Demo.Schemas.Schema1" TargetNamespace="http://Company.Demo.Schemas.Schema1" RootName="Schema1">
    <Description>Company.Demo.Schemas.Schema1, Company.Demo.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b0fe90ef71d5ac4</Description>
  </MessageType>
  <Service Name="Company">
    <Description>service "Company.Demo.Schemas.BizTalk_Orchestration4" port "Port_1"</Description>
    <PortType Name="Company">
      <Description>service "Company.Demo.Schemas.BizTalk_Orchestration4" port "Port_1"</Description>
      <Operation Name="Operation_1" MethodName="Operation_1">
        <Description>operation "Operation_1"</Description>
        <Input Name="__messagetype_Company_Demo_Schemas_Schema1" MessageType="Company.Demo.Schemas.Schema1#Schema1" />
        <Output Name="__messagetype_Company_Demo_Schemas_Schema1" MessageType="Company.Demo.Schemas.Schema1#Schema1" />
      </Operation>
    </PortType>
  </Service>
</BtsServiceDescription>

Unit Testing Biztalk 2010 Artifacts using BizUnit 4.0


Testing XML Schema.

Step 1:Create Schema.Xsd


 











Step 2: 


Create Instance of Schema.Xsd
<ns0:Employee xmlns:ns0="http://Company.Demo.Schemas.Employee">
  <FirstName>Kumar</FirstName>
  <LastName>Janssen</LastName>
  <SocialSecurityNumber>330409710</SocialSecurityNumber>
  <Type>Full</Type>
  <Function>Manager</Function>
  <Salary>50000</Salary>
  <Bonus>1000</Bonus>
  <Pension>1000000</Pension>
</ns0:Employee>

Step 3:



Bizunit Method for testing Instance.xml

  [TestMethod]
        public void TestEmployeeSchema()
        {
            var employeeTest = new TestCase { Name = "Test Schema.Xsd Schema" };

            //Create the file validate step
            var validatingFileReadStep = new FileReadMultipleStep
            {
                DirectoryPath = @"..\..\..\Company.Demo\Company.Demo.Sample.Schemas",
                SearchPattern = "Instance.xml",
                ExpectedNumberOfFiles = 1,
                Timeout = 3000,
                DeleteFiles = false
            };

            //Create an XML Validation step
            //This will check the result against the XSD for the Employee document
            var validation = new XmlValidationStep();
            var employeeSchema = new SchemaDefinition
            {
                XmlSchemaPath =
                @"..\..\..\Company.Demo\Company.Demo.Schemas\Sample.xsd",
                XmlSchemaNameSpace = "http://Company.Demo.Schemas.Employee"
            };
            validation.XmlSchemas.Add(employeeSchema);

            validatingFileReadStep.SubSteps.Add(validation);

            employeeTest.ExecutionSteps.Add(validatingFileReadStep);

            //Execute Tests
            var bizUnit = new BizUnit.BizUnit(employeeContractTest);
            bizUnit.RunTest();
        }

Tuesday 8 January 2013

Insert FlatFile Data into sql Table using Biztalk WCF-SQL Adapter



After completing this tutorial, you will be able to create flat file schema, convert flat file to XML file, build pipeline , build map, create orchestration and call Stored procedure  in a BizTalk application.

Step One Create Flat File Schema

BizTalk provides utilities to easily create flat file or XML file schema.

Create an empty BizTalk project,

Once the project is created, right-click the project and add a new item. Select Flat File Schema Wizard in the new item window and name the file as authors_FF.xsd.





















In the Flat File Schema Information window, specify the location of author.txt file and record name author

Sample File for Author(author.txt)-

LastName,FirstName,Phone,Address,City,State,Zip,Contract
LastName,FirstName,Phone,Address,City,State,Zip,Contract
LastName,FirstName,Phone,Address,City,State,Zip,Contract
LastName,FirstName,Phone,Address,City,State,Zip,Contract
LastName,FirstName,Phone,Address,City,State,Zip,Contract
LastName,FirstName,Phone,Address,City,State,Zip,Contract

·  Choose “By delimiter symbol” in the Select Record Format screen.
·  Select {CR}{LF} as Child delimiter because I used a carriage return and line feed























Once the Child Elements window appears, ensure you change the Element Name of the first row to be readable  authorDetail  and Element Type of the first row to Repeating Record. For other rows, you just set the Element Type to Ignore because other rows just simply repeat the first row.
Then define the record elements by define delimiter as ','.


Step Two Create Pipeline

·          Add receive pipeline using Receive Pipeline template.

·          Drag and drop the Flat File Disassembler component from the toolbox to the pipeline and drop it into the disassemble stage. This component will convert the flat message to XML message.

·          Then choose Author Schema  in the Document schema dropdown list of the property window of the flat file disassembler


Step 3 , Create Stored procedure for insert author data to author table .

Create procedure USP_INS_Authors
@au_lname varchar(20),
@au_fname varchar(20),
@phone char(12),
@address varchar(40),
@city varchar(20),
@state  char(2),
@zip char(5),
@contract  bit
AS
BEGIN

INSERT INTO [pubs].[dbo].[authors]
           ([au_lname]
           ,[au_fname]
           ,[phone]
           ,[address]
           ,[city]
           ,[state]
           ,[zip]
           ,[contract])
     VALUES
           (@au_lname,@au_fname,@phone,@address,@city,@state,@zip,@contract);
END


Create Schema for Stored procedure “USP_INS_Authors“ , using wcf-sql adapter 
Right Click Project , add--> Add Generated Items--> Consume Adapter service

Configure URI





Create Map for transform flatfile to storedprocedure xml.

Select Input as flatfile schema and output as Stored procedure schema



Create Orchestration for receive flatfile , transform that flatfile to xml and send data to data table using wcf-sql



Right Click your project and deploy application