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-
- Visual Studio
- BizTalk Server 2013R2 or later version
- Basic knowledge of JSON
- 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 !!
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.
ReplyDeletePlease 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.
DeleteI checked my map, It's correct. When I am testing the Map then I am getting the fullname, as follows:-
ReplyDeleteAnishKumar
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.
Ok! Please send me your complete code to me so that i can check your issue.
Deletebiztalklive@gmail.com
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.
DeleteI am using Map in send port in outbound section also. after that I am getting same name.
ReplyDeleteSorry 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.
DeleteAll the best.
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.
ReplyDeleteOnce again Thanks You.
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.
ReplyDeleteelv and automation systems uae
This comment has been removed by the author.
ReplyDeleteWhile designing the interior your main concern should be furniture and windows. Blinds play significant role in beautifying the offices.
ReplyDeleteRoman blinds or Shades has power to fully transform your space
roman blinds dubai
ReplyDeleteWe 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
Hi, do yo have some example like this, but using an orchestration? Thanks.
ReplyDeleteNice 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