Tuesday, August 2, 2016

REST with OSB GET method

Simple way to invoke REST with GET method


1. Create a Business Service with URL and use Route action.





2. How to pass parameters?
a. Add insert action -
 


b.Xpath -


./ctx:transport/ctx:request





c. You can create parameters like this
<http:query-parameters>
<http:parameter name="startValue" value="{$startVal}" />
<http:parameter name="end" value="{$endVal}" />
</http:query-parameters>





where startVal /EndVal is a variable created and passed input from Request. Otherwise you can directly use the value instead of Variable.
If there are multiple parameters, include all the parameters here



3.
a.  Transport Header:

b. Content type is required. so use text/xml. few scenarios accepts json/xml or json / text based on the response. In this case expected response is XML



4. Business Service configuration.
a.

b.



c.
Provide appropriate URL other than Query parameters



d.


Select http Request Method - GET







ALTERNATIVE to OPTION


I). Sometimes URL String will be www.xyz.com/testService/inventoryId?startDate=XXXX&time=XXXX


In this case,


use "ASSIGN" action to prepare relative URL


fn:concat($body/testRequest/inventoryId,'?','startDate=',$XXXXXX,'&amp;','time=',XXXX)


prepare URL like this.


If you want to add "&", use  "&amp;".


11).






Expression:
<http:relative-URI>{$relativeURL}</http:relative-URI>
Where relativeURL is from step-I)
xpath:


./ctx:transport/ctx:request


In Variable always 'outbound'.




 111) Follow the steps from 3 and 4 from the OPTION-1










Confused? More questions? send me an email.. Will respond back




- Cheers














No comments:

Post a Comment