Implementation of JSON message in BizTalk Application Skip to main content

Implementation of JSON message in BizTalk Application


Today ! In this post I will tell you, complete solution of implementation of JSON messages in BizTalk with an example. As you all know very well that JSON (JavaScript Object Notation) is a lightweight data-interchange format and it is also language independent.
These are below following prerequisites to implement JSON message in Biztalk-
  1. Visual Studio
  2. BizTalk Server 2013R2 or later version
  3. Basic knowledge of JSON
  4. Basic knowledge of programming in BizTalk and deployment.

 I am going to tell you how to receive JSON message with the help of JSON decoder tool in receive pipeline and same how to send JSON message with the help of JSON encoder tool in send pipeline. Without waste your time, please follows below all steps to achieve JSON message in BizTalk.

1. Open Microsoft visual studio and create new biztalk project name as 'BizTalkLive_JSONExample1' then right click of this biztalk project and select property and set Application name as 'BizTalkLive_JSONExample1' from Deployment tab and also create strong name key in Signing tab, name as 'snBizTalkLive_JSONExample1.snk'. See the following image-
2. Firstly, I have created one simple input schema of employee name list and this schema details are, one root name as Employees then create child level of one records name as Employee and in last create two child elements within this Employee records name as 'fName' and 'lName' simultaneously. See the below picture for your reference-
3. In similar way, I have created output schema of Employees full name list and this schema details are, one root name as Employees then create child level of one records name as 'Employees' and in last create one child element within this Employee records name as 'fullName'. See the below image for your reference to create this output schema-
4. Now, create one map name as 'Name_To_fullName.btm' then select source schema 'NameList.xsd' and destination schema 'FullNameList.xsd'. Mapped both schema as shown in the below picture-
5. As we all know that in biztalk internal flow of message in only XML format so I need one receive pipeline that decode JSON message to XML message. So now create one receive pipeline and name as 'RcvJSONNameList.btp' then select JSON decoder tool from pipeline toolbox and drop it in Decode stage of pipeline. There are three pipeline component properties i.e.
  • Add Message Body For Empty Message - True or False ==> if it true, for empty message, '{}' will be added as message body. I do not want to add '{}' for empty message so will set as false value for it.
  • Root Node - Root name of my input schema after conversion of JSON message to XML format in my case it is 'Employees'.
  • Root Node Namespace- Target namespace of my input schema in my case this value is 'http://BizTalkLive_JSONExample1.JSONSchemaNameList'
above three properties, we can also set after deploy of this biztalk application,  see the following picture for your reference to create receive pipeline-
6. One more important step i.e. how to encode xml message to JSON. So create send pipeline and name as 'SndJSONFullNameList.btp' then select JSON encoder tool from pipeline toolbox and drop it in Encode stage of pipeline. There is only one pipeline component property i.e. Remove Outer Envelope - True or False ==> if it true then root element of xml message to be ignore after encoding so in my case it should be 'false'. See the below image for your reference to create this send pipeline-
7. Now build this biztalk solution and deployed it then create one receive port name as 'RP_JSONGetNameList' within this receive port create one receive location name as  'RL_JSONGetNameList' and choose transport type as 'File' after that choose one of file handler then select receive pipeline 'RcvJSONNameList' that i have already created it for decoding JSON to xml message. In last, click configure button and set receive folder directory. See the below picture for your reference to create receive location to get JSON message-
8. Create one send port and name as 'SP_JSONFullName' then select transport type as 'File' after that select send pipeline 'SndJSONFullNameList' (Encode xml message to JSON) and then click on configure button and set destination folder path here and file name as '%MessageID%.json'. Click OK and go to Filters tab of same send port and one filter property of BTS.ReceivePortName==RP_JSONGetNameList so that when JSON message publish on receive port then it will be subscribed by this send port. And also do not forget choose your MAP from Outbound Maps of tab section . See this following picture to create send port-
9. In this last step Create one .json file of Employees name list as per my input schema of employees name list. I have created one JSON file name as 'EmployeeNameList.json' and to do this, open notepad  then copy below JSON format text and save as 'EmployeeNameList.json'.

{"Employee":[
  { "fName":"Jitendra", "lName":"Yadav" },
  { "fName":"Sushil", "lName":"Singh" },
  { "fName":"Sarita", "lName":"Rani" }
]}

Great !! I have completed all steps to implement of JSON messages in biztalk server. Now restart host instance and drop JSON message of employees name list in test folder of receive location folder and get full name of JSON message of employees list on given destination folder in send port of this BizTalk application.

!! To do BizTalking then Keep visiting BizTalkLive !!

Comments

  1. Bro, In Output I am not getting convert string as FullName like fname is Anish and lname is kumar, FullName is not coming as Anish Kumar in output, it is coming same as input string in output. can you check once? I need your help.

    ReplyDelete
    Replies
    1. Please check you map, may be your destination map schema will be same. Please see again my map and schema and do in the same way, there is no issue.

      Delete
  2. I checked my map, It's correct. When I am testing the Map then I am getting the fullname, as follows:-


    AnishKumar


    ManishKumar


    rahulKumar



    while testing the map, It's coming correct but in pipeline, I am not getting fullname rather I am getting same input schema. can you help me.

    Can you simple describe one example of receive and send pipeline, two schema and mapping creating in visual studio and after the passing of pipeline , we will get output as destination schema (conversion must take place with help of Mapping not orchestration). use file type as xml.

    Please help me, I am facing this issue since 2 week.

    ReplyDelete
    Replies
    1. Ok! Please send me your complete code to me so that i can check your issue.

      biztalklive@gmail.com

      Delete
    2. Hello Anish, You are getting same name because you do not use MAP in your send port. Click your send port then select your MAP from outbound map tab section.

      Delete
  3. I am using Map in send port in outbound section also. after that I am getting same name.

    ReplyDelete
    Replies
    1. Sorry for late reply, due to health problem I could not reply on time. After test your code I have found issue in receive pipeline, only you add XML disassembler in Disassemble stage of your receive pipeline then restart receive host.

      All the best.

      Delete
  4. Thank you for solving this issue.!! if Possible Please make one blog for use of dissemble stage in receive pipeline and assemble in send pipeline using properties document Schema and Envelope Schema in send and receive pipeline. It's help me a lot for me and other users.


    Once again Thanks You.

    ReplyDelete
  5. Hedges Information Technology LLC is a leading and established IT, ELV & AUTOMATION System Integrator based in Dubai, U.A.E, with over a decade of experience catering to key business verticals in SMB, Mid-market & Enterprise accounts.
    elv and automation systems uae

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. While designing the interior your main concern should be furniture and windows. Blinds play significant role in beautifying the offices.
    Roman blinds or Shades has power to fully transform your space
    roman blinds dubai

    ReplyDelete


  8. We offer 14 days easy return and exchange if goods have any problems. Please email us at sales@zamarah.com if you would like to request a return.
    melissa and doug

    ReplyDelete
  9. Hi, do yo have some example like this, but using an orchestration? Thanks.

    ReplyDelete
  10. Nice Blog with useful information. The server management plan comes with round the clock support. You can open a support ticket to us at any time of the day or night, and we will be here to make sure that everything runs perfectly to your satisfaction. For More Details visit on our website.

    ReplyDelete

Post a Comment

Please write comment only that belongs to this blog

Popular posts from this blog

BizTalk Interview Question and Answer

1. What is BizTalk? BizTalk is a middleware that sits in the middle of any two software who wish to communicate with each other and agree on some specified communication pattern. It uses SQL Server as back end database. “Microsoft BizTalk Server is an Inter-Organizational Middleware System (IOMS) that enables companies to automate business processes, through the use of adapters which are tailored to communicate with different software systems used in an enterprise. Created by Microsoft, it provides enterprise application integration, business process automation, business-to-business communication, message broker and business activity monitoring.”                 2. What is BizTalk Server Architecture and Life Cycle of Message? BizTalk Server Architecture: Life Cycle of Message: In this simplified view, a message is received through a receive location defined in a given receive port. This message is processed by the receive locatio

Configuring BizTalk WCF Timeout Values on a Binding

There are a number of timeout settings available in WCF bindings. Setting these timeout settings correctly can improve not only your service’s performance but also play a role in the usability and security of your service. The following timeouts are available on WCF bindings: OpenTimeout CloseTimeout SendTimeout ReceiveTimeout Open Timeout :  This property represents the amount of time a channel open operation has to complete. Send Timeout :  Use this property to set the amount of time that a send operation has to complete. When used as part of a solicit-response scenario, this value encompasses the total amount of time for the interaction to complete. If we are sending a large message, we may need to increase this timeout to allow for the request and response messages to be processed within this window. Close Timeout :  A time-stamp that is used to indicate the amount Receive Timeout :  Used by the Service Framework Layer to initialize the session-idle timeo

PowerShell Script to enable BizTalk Receive Location

We are facing problem in BizTalk server 2016 that few of running SFTP Receive location would be stopped after some time due to sftp connectivity issue of their threshold so I am going to share PowerShell script to enable receive location by window task scheduler. Before execute following script Please do following task a. Set Server name in ConnectionString b. Set ( $hostname) host name value that is using in SFTP Receive location c. Set ( $rcvLocation) Receive location name # Import external assembly and create a new object [ void ] [ System.reflection.Assembly ]:: LoadWithPartialName( "Microsoft.BizTalk.ExplorerOM" ) $Catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer   #BizTalk Config $Catalog . ConnectionString = "SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI"   #connectionstring for the BizTalkMgmtDb $hostname = "BizTalkServerApplication" #hostname $rcvLocation = "RL_GetAccReq_SQL

Step by step solution of BizTalk Two-Way WCF-SQL XmlPolling in Send Port

I am going to share most awaited Two way WCF_SQL Two Way XmlPolling so that you can easily enhance your old SQL procedure and BizTalk Map without any big change. I know there is no content available in any website to how work with XmlPolling in WCF-SQL two-way adapter. In the last of this post you can download complete source code with an example. Please follow carefully all steps – 1. Open Microsoft Visual Studio as Administrator user and Click File>New>Project… In Installed Templates click BizTalk Projects then Empty BizTalk Server Project and Name as “BizTalkLive-WCF-SQL” and click OK. 2. Now see the below picture and create all respective folders separately for Schema, Map, Orchestration, Pipeline, Binding- 3. Create Schemas in Schema folder as shown below picture to get Account request using One Way WCF-SQL XmlPolling a) Create Envelope Schema first with Target NameSpace - http://BizTalkLive_WCF_SQL.AccountRequest b) Create Second Sch

Publish a web service in biztalk using BizTalk WCF Service Publishing Wizard

Welcome you again in my Blog and let us do another mind blowing achievement that how to publish a WCF web service in BizTalk and as in previous post to Complete BizTalk project to host Schema as Web Service  so If you want to expose/publish a web service, you should run through the BizTalk WCF Service Publishing Wizard. This wizard guides you through choosing what you want to expose as a web service. This section walks you through the wizard step by step to publish WCF Web Service using  WCF-WSHttp- Step-1:  To start the wizard, go to Start, All Programs, Microsoft BizTalk Server 2016(version), BizTalk WCF Service Publishing Wizard. This fires up a welcoming screen, on which you just click Next. Consider disabling the welcoming screen for the future by checking the check box at the bottom. You will now see the screen shown in above figure. Step-2: Choose the Service Endpoint option, and choose which adapter to use. Check Enable Metadata Endpoint if you want to expose t