In previous posts on the new adapters available with BizTalk Server 2013 I discussed both the Relay adapters: BasicHttp, NetTcpRelay and the Service Bus SB-Messaging. In this post I like to discuss the WCF-WebHttp adapter in his current state in the BizTalk Server 2013 Beta. The adapter offers the capability to send messages and to receive messages from a RESTful Service endpoints.
Note: Since BizTalk sends out message bodies you will need to configure the adapter to prevent this for the GET and DELETE request . This configuration currently is not available yet and the current option (with BizTalk Server 2013 Beta) is to remove the message body with a pipeline.
Below you find a diagram of a scenario I like to walk-through, where I consume a RESTFul Service endpoint of the US Federal Aviation Administration. From a client application I will send a request for the status of an airport, which will by BizTalk to the Restful service endpoint.This endpoint will provide the status of a given airport based upon the airport code I provide within the request URL. The result will be routed back to the client application.
The GET request is the fundamental, widely used operation in REST world. You can simply visit a URL in a browser (or programmatically); for instance in this case for instance the following URL http://services.faa.gov/airport/status/SEA?format=xml and the browser returns a machine understandable structured data like below:
To get this done through BizTalk you need to configure a send port with the WCF-WebHttp adapter. The following picture shows the WCF-WebHttp REST adapter configuration. In the general tab the address URL, the HTTP Method and URL mapping are specified.
In the address the URI for the REST interface where the message is sent is specified. The HTTP method to URL mapping can be specified as a singular format or a multi-mapping format. In this sample it is multi-mapping format. The Variable mapping is specified by click the Edit… button.
Variable mapping is a technique that enables you to parameterize your request to a RESTful endpoint. Hard coding the airport code is not a viable option. The other tabs provide you ability to configure the time-out and encoding-related properties, define the security capabilities of the WCF-WebHttp send port, configure the endpoint behavior for the send port and configure the proxy setting for the WCF-WebHttp send port. For this sample all these are left untouched (default).
When I start the client I can select an airport in the US and request the status.
The request will be sent to an WsHttp endpoint in BizTalk Server. This endpoint is created through BizTalk WCF Publsihing Wizard exposing the following schema.
The request will be routed to the send port with WCF-WebHttp adapter, which will sent the request i.e. request resources through the GET method based on the following:
The result is mapped back to response message of the WsHttp endpoint and returned to client for rendering the UI. You can download this solution from the Code Gallery.
Other resources related to the WCF-WebHttp worth to check out are:
- Exploring REST Capabilities of BizTalk Server 2013 (Part 1: Exposing REST Endpoints)
- Exploring REST Capabilities of BizTalk Server 2013 (Part 2: Consuming REST Endpoints)
- REST (WCF-WebHttp) adapter in BizTalk Server 2010 R2 and code
- BizTalk and Rest Example from BizTalk Saturday