POST method at Receive Port

POST Method does not send data in URL Parameters as GET Method sends. In Post method, Rest Service sends data in Message body. Mostly this is in json format. When BizTalk Receive this file, then through the use of JSON decoder pipeline component, BizTalk convert the json into xml format.

For Pipeline configuration related information, you can refer to below reference:

https://vkbiztalk.wordpress.com/2017/06/14/biztalk-with-rest-services/

At BizTalk Receive port we just adding a   below details in HTTP Method and URL mapping in Wcf-WebHttp adopter configuration.

<BtsHttpUrlMapping><Operation Name=”<Name>” Method=”POST” Url=’/OperationName/Request’ /></BtsHttpUrlMapping>

Rest11.jpg

Here no need to do anything with Variable mapping. Apply “Content-Type:application/json” to process data as JSON.

rest15.jpg

Note: For Get Operation we have to keep GET verb in Incoming Message, for Post operations keep blank only.

POST Method at Send Port:

In case of when BizTalk consuming Rest Service through its Send Port with Wcf-WebHttp adopter, then its configuration is same as in Receive Port except one nominal change in below configuration.

<BtsHttpUrlMapping><Operation Name=”” Method=”<REST METHOD>” Url=’/OperationName/Request’ /></BtsHttpUrlMapping> 

There is not require to provide Operation name, we can leave it blank as above.

Advertisements

GET method at Receive Port

When we publish BizTalk as REST Service, then it’s not directly linked with Schema or Orchestration like WCF or Web Service does. in my previous blog, I have mentioned how to publish BizTalk as REST Service with help of BizTalk WCF Service Publishing Wizard Tool.

https://vkbiztalk.wordpress.com/2017/06/17/publish-biztalk-as-rest-service/

Here when we define the action configuration in Receive Location in that we provide Message Context property BTS.Operation for Operation Name, through this message context property, incoming message can link with orchestration Receive Port or Send Port with applying details in Filter. In below example

<BtsHttpUrlMapping><Operation Name=”TESTGETMETHOD” Method=”GET” Url=’/OperationName/Request?Param1={param1}&amp;Param2={param2}’ /></BtsHttpUrlMapping>

Here Operation name is TESTGETMETHOD. So BTS.Operation Message Context Property is stand for TESTGETMETHOD.

For Pipeline configuration related information, you can refer to below reference:

https://vkbiztalk.wordpress.com/2017/06/14/biztalk-with-rest-services/ 

The purpose of enabling GET operation is to fetch data from target system. Other perspective is when request parameters are few in count wise, then we can go with GET API URL.

We will discuss the configuration details at receive location transport level for GET operation.

  • Promote the elements (Param1 and Param2) from message schema whose elements are going to use in GET API URL.
  • Navigate transportation configuration of the REST API receive location and add below text in HTTP method and URL mapping shown in below snap.
  • <BtsHttpUrlMapping><Operation Name=”<Name>” Method=”GET” Url=’/OperationName/Request?Param1={param1}&amp;Param2={param2}’ /></BtsHttpUrlMapping>
  • If there is not require any parameter in GET method then no need to add parameters in BizTalk Schema.
  • Rest11.jpg
  • Map the elements with property schema element names and namespace as below.

rest14.jpg

In GEt method of REST Service, there is no message body. Information is sending in URL as Parameter as in below example:

http://localhost/BizTalkRestService/Service1.svc/Request?Param1=Test1&Param2=test2

here Param1 and Param2 are the two parameters of the GET method. Now We need to understand how BizTalk work with this. In above screen shot we are defining Variable Mapping. In variable Mapping, we are assigning parameters with Property Schema. We need to define Property Schema variable with Message Context Property. Otherwise it will not assign any value.

Rest13_PropertySchema.jpg

Create your property schema with those properties, set the Property Schema Base to MessageContextPropertyBase.

When BizTalk receive request with JSON decoder pipeline, then its create message.

Receive location transportation url would be like this: /BizTalkRestServiceTest/Service1.svc

GET Method at Send Port:

In case of when BizTalk consuming Rest Service through its Send Port with Wcf-WebHttp adopter, then its configuration is same as in Receive Port except one nominal change in below configuration.

<BtsHttpUrlMapping><Operation Name=”” Method=”<REST METHOD>” Url=’/OperationName/Request’ /></BtsHttpUrlMapping> 

There is not require to provide Operation name, we can leave it blank as above.

Publish BizTalk as REST Service

One of the features in BizTalk 2013 R2 is to integrate REST API with other systems/entities. As data process via JSON format we use JSON relevant pipelines to have syntax transformation (JSON to XML and vice versa).  In this article, we will share how to expose REST service in BizTalk and configure it at receive and send port level.

For more about json pipeline, you can refer to my previous blog BizTalk with Rest Service.

https://vkbiztalk.wordpress.com/2017/06/14/biztalk-with-rest-services/

We can categorize aforementioned process into below steps.

Step1: Expose REST API in BizTalk and apply in Receive stage.

Step2: Apply GET method at Receive Port

Step3: Apply POST method at Receive Port

Step4: How to test from Postman UI

Step1: 

Configure REST API using BizTalk WCF Service Publishing Wizard so that it creates service in IIS and Receive location in admin console.

  • Open BizTalk WCF Service Publishing Wizard Tool and click on Next button in Home page and below screen populates.
  • Select WCF-WebHttp adapter and enable second check box and select respective BizTalk application name and click on Next.

Rest1.jpg

Click Next in below screen

Rest2.jpg

Select Receive Port Type as per Business requirement as below screen

Rest4.jpg

Provide relevant name in URL for the service as below screen

Rest5.jpg

Click Next

Rest6.jpg

Now you can see the XSLD has ready to generate for this Rest Service. Click on Create> and finish the process.

Rest7.jpg

Now the BizTalk WCF Service Publishing Wizard work is done. Next is just configuration change require on IIS and Receive Port.

Open IIS manager and select the BiztalkRestServiceTest Service and set up the Advance Settings

Rest8.jpg

Start the Newly Created Receive Location in BizTalk Admin Console, then browse the Service from IIS. By default, its URL is created with Service1.svc.

Rest9.jpg

Ensure that below settings available in web.config file.

Rest10.jpg

WCF Service in IIS and BizTalk Receive location is created so far.

In below reference, its defined to convert .svc url into REST API url.

Convert .svc URL to Rest API URL

https://vkbiztalk.wordpress.com/2017/06/17/convert-svc-url-to-rest-api-url/

We can change the URL as defined above. It’s not recommended but good to look that BizTalk publish as REST Service then its URL also look like as REST Service.

Step2:  Apply GET method at receive port.

Receive Port Configuration is provided in next blog as below:

https://vkbiztalk.wordpress.com/2017/06/17/get-method-at-receive-port/

Step3: Apply POST Method at Receive Post:

Receive Port Configuration is provided in next blog as below:

https://vkbiztalk.wordpress.com/2017/06/19/post-method-at-receive-port/

 

 

Convert svc URL to REST API URL

When we publish BizTalk as REST Service, then it’s generate as below by default.

http://localhost/<ApplicationName>/Service1.svc

when we apply REST verb with this URL, then it’s become as below for Business User.

For GET Method:

http://localhost/<ApplicationName>/Service1.svc/Request?Data1={data}&Data2={data}

For POST Method:

http://localhost/<ApplicationName>/Service1.svc/Request

We can change the Service1 name with some other name but can’t change the .svc.

So, for outer world (Consumer), it’s look like they are consuming the WCF Service instead of REST Service.

So, making feel like as REST Service we need to do some small thing as below:

  • Install Microsoft Rewrite URL module 2.0 (it’s freeware) for IIS to accept the rewrite tags in service configuration files.

https://www.microsoft.com/en-in/download/details.aspx?id=7435

  • Add below rewrite module entries in service web.config file to enable us to use api name in service URL.

<system.webServer>

<rewrite>

<rules>

<rule name=”TestService1”>

<match url=”/Service1(.*)” />

<action type=”Rewrite” url=”Service1.svc/{R:0}” />

<conditions>

<add input=”{REQUEST_METHOD}” pattern=”GET” />

</conditions>

                     </rule>

                     <rule name=”TestService2”>

<match url=”/Service2(.*)” />

<action type=”Rewrite” url=”Service2.svc/{R:0}” />

<conditions>

<add input=”{REQUEST_METHOD}” pattern=”POST” />

</conditions>

</rule>

</rules>

</rewrite></system.webServer>

  • URL will refer as below instead of Service1.svc at postfix.

GET Method:

http://localhost/<ApplicationName>/api/Request?Data1={data}&Data2={data}

For POST Method:

http://localhost/<ApplicationName>/api/Request

Implementation of BAM Activity Definition file

When we install BAM in BizTalk Server then its add BAM (Business Activity Monitoring) in Add-Ins in Microsoft Excel File. For implementation of BAM or create Activity Definition file of BAM we need to follow the following process.

Open Excel File -> File -> Options -> Add-Ins

BAM1.jpg

Click on Go… Button as in above screenshot. Now below popup will open, Select the Business Activity Monitoring and click OK.

BAM2.jpg

Now click on Add-Ins Tab in Excel file as below screenshot. And select BAM Activity. as defined below.

BAM3.jpg

Now Activity Definition file will open as below:

BAM4.jpg

Here we need to define the data and milestone, which will need to capture from the BizTalk applications when message process.

Here I have defined some data as below screenshot:

BAM5.jpg

Item type as Business Milestone is related to Date Time.

BAM6.jpg

BAM7.jpg

BAM8.jpg

After defining Activity data, we can also define these things in BAM View as below to look more familiar to Business Users.

BAM9.jpg

BAM10.jpg

BAM11.jpg

BAM12.jpg

Now if require then we can go for below feature otherwise we can escape this.

BAM13.jpg

BAM14.jpg

Click next and finish the Activity Creation.

After finishing the creation of Activity details, we need to export then details in xml format as defined below:

BAM15.jpg

BAM Definition file will look like as below:

BAM16.jpg

Now we need to execute the below command to setup the activity Details in BAMPrimaryImport Database.

bm.exe deploy-all -DefinitionFile:<def file>[ -Server:<server> ][ -Database:<database> ]

BAM17.jpg

The BAM management utility deployment commands allow you to apply, modify, and remove definitions.

  • exe deploy-all: Deploys a BAM definition.
  • exe update-all: Updates a BAM definition.
  • exe remove-all: Removes a BAM definition.

BAM Portal:

Now you can check this on BAM Portal. If you run BAM Portal first time then need to set the Compatibility View Setting on Internet Explorer. If you want to open BAM Portal on Google Crome then you need to add IE Tab in Crome.

For more information about how to open BAM in different browser, you can refer below reference:

https://blog.sandro-pereira.com/2015/07/31/user-experience-running-bam-portal-in-different-browsers/

BAM18.jpg

For more information about BAM, please refer the below reference:

https://msdn.microsoft.com/en-us/library/aa558802.aspx

https://msdn.microsoft.com/en-us/library/aa560294.aspx