Posts

Showing posts from September, 2023

Error handling using nested scopes used for API calls via BizTalk

Introduction Think about a scenario where you need to send a request to an API and capture error responses for HTTP status codes other than 200, as well as for HTTP status code 200. You can use the logic below to achieve this. Steps The main scope captures errors related to HTTP status codes other than 200, while the child scope captures errors for HTTP status code 200. In the child orchestration, we check a specific field in the response. If the field is not populated with a value, we know that there is an error and can handle it accordingly. Main Scope {     //Send API request to API     //Receive response     Child scope    {     //Check for a particular Business identifier in the response message.For example, check invoice ID is present in the response message     //Throw custom exception     }     Child Catch block    {     //Catch custom errors     //Log custom errors ...

Custom Exceptions in BizTalk

Image
Introduction Think about a scenario in which we receive a response from a stored procedure and if the response is an error, we need to abort the transaction with a custom error message and route it to the catch block. We can accomplish this using custom error handling in BizTalk. Steps: In the orchestration code block where you need to capture the custom error, place an expression shape.   Now insert the below line of code in the Expression shape: objException = new System . Exception ( insertStatus );   " ObjException " is a variable of type ' System.Exception' Below the expression shape, place a ' Throw Exception ' shape with an exception object of 'ObjException .' By doing this, we are throwing a custom exception, and the catch block will capture the custom errors and process them as configured in the catch block.

Creating a flat file Schema using Flat File Schema Wizard - Comma delimited flat file

Image
 Introduction In this blog post, we will try to understand how to create a flat file schema using a flat file schema wizard. Steps Let's use the flat file below to generate the schema. Invoice Number,Date,Customer Name,Customer Address,Item Description,Quantity,Unit Price,Total INV-2023-001,2023-09-23,John Doe,123 Main St,Product A,5,10.00,50.00 INV-2023-002,2023-09-24,Jane Smith,456 Elm St,Product B,3,15.00,45.00 INV-2023-003,2023-09-25,Bob Johnson,789 Oak St,Product C,2,20.00,40.00 Create a new BizTalk project and solution and name it POCFlatFileSchema Right Click on the project --> Add New Item Provide the instance file path, Name the record as "Invoice" and code page as shown below First we need to define the records and then elements within the record. The schema wizard will walk us through the process. Select the first record as shown below and click next Invoice Number,Date,Customer Name,Customer Address,Item Description,Quantity,Unit Price,Total¶« This is the c...

Start Orchestration in BizTalk

Image
Introduction In this blog, we will try to understand the basics of start orchestration in BizTalk. Sometimes, there's a need to trigger another orchestration for processing without expecting control to return to the parent orchestration. In such scenarios, opting for Start Orchestration is a viable solution. This approach allows us to implement separate error handling within the child orchestration. The parent orchestration continues its execution without waiting for control to return, advancing through the remaining steps in the business process. Scenario Source A message is received by Process A orchestration which is the parent or the main orchestration It then does a transformation and then Starts the Process B orchestration. Process B orchestration sends out the message to another system. Error handling is done for the send operation High Level Steps Receive SourceA File in ProcessA orch Define message variables msgSourceA of type SourceA schema and msgSourceB of type Source B...

Basics of Correlation in BizTalk

Image
 Introduction In this blog, we will try to understand the basics of Correlation. In some cases, we would want the message to be correlated to another message in the message box and we can use correlation set and correlation Type to achieve this. Sometimes, it's not just about connecting messages. We may also need to attach additional properties to a message, such as a unique GUID or an application identifier, and promote these properties on to the context. We can also achieve this using Correlation Type and correlation set. Think of Correlation Type as a class, and Correlation Set as an instance of that Class.  Process Flow Schema Creation Create an Order schema with a field called Order. Distinguish this field Create an Ack Schema with a field called Status Create a Property Schema with 4 fields and set the property base of the fields to "MessageContextPropertyBase": Application Order Application1 Order1 Maps Create a map and name it "Order_TO_Ack". Source Sche...