BizTalk 2012 R2 and REST Example Walkthrough

The recent BizTalk 2012 R2 release has inbuilt REST support for both exposing, and consuming a REST service using the WebHttp binding

In this blog post I will provide a walkthrough on how to configure BizTalk to:

  1. Expose an Orchestration as REST service (POST).
  2. Consume a REST service (POST).

We will use the Hello World orchestration example that is part of the SDK.

  1. Expose an Orchestration as REST service (POST):
    1. Deploy the HelloWorld Orchestration sample and test to make sure everything works as expected
    2. Modify the receive port
      1. Modify the Transport type to use WCF-WebHttp and click to configure

      2. Update the url mapping to the following, the operation name string should be the same operation name used in the orchestration.

        <BtsHttpUrlMapping>

        <Operation Name=”Operation_1″ Method=”POST” Url=”/HelloWorld”/>

        </BtsHttpUrlMapping>



      3. Save and restart the orchestration and BizTalk Services.
      4. Launch Fiddler and submit a request to the url http://localhost/HelloWorld and you will see a new file created in the folder C:\Program Files (x86)\Microsoft BizTalk Server 2010 R2\SDK\Samples\Orchestrations\HelloWorld\Out (note: this is the default installation path).

  2. Consume a Rest service (POST)
    1. Create a new MVC app, with webapi controller and modify the the Post method of the ValuesController to the following to accept a generic HttpRequestMessage (or you could probably do an xsd.exe and import the generated cs file into the mvc project and add it as an parameter, this I will cover in the later posts).
      1. public
        void Post(HttpRequestMessage value)

    2. Modify the send port:
      1. Modify the transport to use Wcf-WebHttp binding and click on configure

      2. Update the url mapping to the following, the operation name string should be the same operation name used in the orchestration.

        <BtsHttpUrlMapping>

        <Operation Name=”Operation_1″ Method=”POST” Url=”/api/values/post”/>

        </BtsHttpUrlMapping>

      3. And in the post you could probably send it to another downstream service or write it to a file or something.
  3. In the upcoming posts I will show you on how to use other the other http verbs, use cases and add JSON support.