How to call RESTFULL service using Dynamic Ports with Variable Mapping in WCF-WebHttp Adapter

The following TechNet article describes on how to call a RESTFull Service from WCF-WebHttp Adapter in BizTalk 2013.
https://social.technet.microsoft.com/wiki/contents/articles/18935.biztalk-server-2013-consuming-a-restful-endpoint-using-wcf-webhttp.aspx

 However, in this blog, we will discuss how to implement the same solution using Dynamic Send Ports and receiving the response in BizTalk Server. 

The application works as follows:
We receive an incoming message containing the name of the Airport Code for which we want to receive the weather conditions. Then we create a binding in the orchestration for the dynamic send port to call the RESTFull service: https://services.faa.gov/airport/status/<AirPortCode>?format=xml
The details of the service can be found at: https://services.faa.gov/docs/services/airport/
The response will be received back in the application and send back to the File location. 

Here is the step by step description on how to achieve this:

1. Create a new application and create a following schema:

Now do a Quick Promotion for the AirportCode.This will allow Visual Studio to add the property schema. In the Property Schema, Delete the Property1 node.

2. In the orchestration, after the receive shape create a construct shape and add the following code:
   
/*Creating a new output message */

output = input;
output(*)= input(*);

/*this part of the code defines how to set the variable mapping. The APC variable will contain the promoted property value. */
output(WCF.VariablePropertyMapping)= @"<?xml version='1.0' encoding='utf-16'?>
<BtsVariablePropertyMapping xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='https://www.w3.org/2001/XMLSchema'>
<Variable Name='APC' PropertyName='AirportCode' PropertyNamespace='https://TestDynamicPort.PropertySchema' />
</BtsVariablePropertyMapping>";

/*Next we define the Outbound Message Property as in the Messages Tab in the send port */
output(WCF.SuppressMessageBodyForHttpVerbs)="GET";

/*Define transport properties */
output(WCF.SecurityMode)="transport";

/*Here we define the Action as we define in the General tab. Here my port is names as Port_2*/
output(WCF.HttpMethodAndUrl)=@"<BtsHttpUrlMapping> <Operation Method='GET' Url='status/{APC}?format=xml' /></BtsHttpUrlMapping>";

   Port_2(Microsoft.XLANGs.BaseTypes.Address)=System.String.Format("https://services.faa.gov/airport/”);
Port_2(Microsoft.XLANGs.BaseTypes.TransportType)="WCF-WebHttp"; 3. Now create a Request-Response port and specify as: 

 4. At this point the orchestration should look something like this:

5. Deploy the application.

6. Next create a physical receive location to receive the input message :
    <ns0:AirportStatusRequest xmlns:ns0="https://TestDynamicPort.AirportStatusRequest">
    <AirportCode>SEA</AirportCode>
    </ns0:AirportStatusRequest>

 7. Create a send port to send the response message to a physical location.

You should now be able to consume a RESTFull Service in BizTalk Server using Dynamic Send ports to create bindings.

Hope this helps.. !!!

Written By
Rasika Chaudhary

Reviewed BY
Jainath Ramanathan

Microsoft GTSC

Comments

  • Anonymous
    September 23, 2016
    hi,I have wcf-webhttp adapter for request and response. in request i am sending xml as json(jsonpipeline is converting ) but in the response i am getting msg as {"Message":"Failed","Content":null,"Status":false} . I have configured webhttp adapter for post operation but still i am not getting successfull message.