In this article, I brief about creating a BizTalk Web Service by exposing schema as WCF Service and then build workflow to perform CRUD operations on entity.
Let’s create a BizTalk project and add a new simple Request and Response schema as shown; this schema would be exposed as web service. Here, I have promoted (custom property) operation as message data context property. CRUD operation happen using this message data context property.
Let us build the orchestration to perform the CRUD operation on the Techie Entity. Bring in a Listen Shape and then create logical two-way request response port and add operations (POST, GET, GETBY and PUT) as shown.
For our ease, we would build 3 flows for Post, Get and GetBy.
We would receive the InfoReq and respond back to the client with InfoRes and just to keep it simple most of the Entity related manipulation would happen thru helper class; this would interact with DB to perform CRUD operation.
Here is our DBHelper class, which uses ADO.net namespaces.
At high-level, on receiving a message; specific flow would triggered based on the operation type (message data context property) and corresponding DB operations are performed thru DBHelper class. Eventually InfoRes is constructed and echoed back to client.
Now, let’s publish the schema as WCF-Service with Custom-Isolated Transport type and opt to create the receive port which would bound to orchestration. Test and verify the flow.
We can convert the web service to restful service just by choosing WCF-Service with WCF-WebHttp Transport type, I made few change over here in the orchestration, instead of using message data context property (Operation) in Receive filters, I used BTS.Operation. To support rest capabilities, I add new context properties such as ID,TechieName etc and renamed the Operation names to be more meaningful. I created and any type msg and mapped to the receive shapes on the Get flows, as we would be suppressing the body of the message in case of HTTP GET verb operation.
Go to Admin Console, add BTS Action URLS and map the URL Param variables to corresponding context properties and set GET operation to suppress the message body.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.