Tuesday, February 19, 2013

How to send a message to REST service from OSB

If we want to post a message to REST service using OSB, we can do it in the following way.

Step1 : Create an generic business service.

  Select the type as Messaging Service


Choose xml as input and output message type


Select the default options in the next tabs and give the endpoint of the REST service to be invoked
 
Thats all we need to do for the business service.

Step2: Create a proxy service of xml service type


Select the defaults and complete the configuration of the proxy service.

Step 3: Create a message flow as shown below. Invoke the above created business service in the message flow as a service call out.

In the Request Action step do the following .

The first assign statement set the payload to be send to the REST service.

The critical steps are the following.

Using the TransportHeader step, set the headers to consume the rest service as shown below

In the next Insert step, overwrite the HTTP method to whatever we require. i.e: GET,POST,PUT,DELETE.MERGE etc.



Thats about the service configuration. Now test the proxy service by sending the required payload for the REST service.


6 comments:

  1. Thanks the last slide helped a lot.
    I was struggling to make the GET call. The last slide shows how to make that call using service callout.

    ReplyDelete
  2. I'm having trouble creating a POST because it sends the soap-env:Body tag before the xml... Any ideas on how to remove it?

    ReplyDelete
  3. you may do one assign activity which will assign only the body part to the service callout out put variable like $body/*

    ReplyDelete
  4. What to write in the first assign statement? I am completely new to OSB and trying to do exactly the above for a critical requirement

    ReplyDelete
  5. set the the payload which you want to send to the target service as the child element of body. Means assign the payload to body. ( replace the node content or the entire node)

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete