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:
- Expose an Orchestration as REST service (POST).
- Consume a REST service (POST).
We will use the Hello World orchestration example that is part of the SDK.
-
Expose an Orchestration as REST service (POST):
- Deploy the HelloWorld Orchestration sample and test to make sure everything works as expected
-
Modify the receive port
-
Modify the Transport type to use WCF-WebHttp and click to configure
-
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>
- Save and restart the orchestration and BizTalk Services.
- 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).
-
-
Consume a Rest service (POST)
-
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).
- public
void Post(HttpRequestMessage value)
- public
-
Modify the send port:
-
Modify the transport to use Wcf-WebHttp binding and click on configure
-
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>
-
And in the post you could probably send it to another downstream service or write it to a file or something.
-
-
- In the upcoming posts I will show you on how to use other the other http verbs, use cases and add JSON support.