Tuesday, April 17, 2012

REST enabling a service via OEG (Oracle Enterprise Gateway)

I have web service enabled the following Java class.

package productservices;

public class ProductServiceImpl {
public ProductServiceImpl() {
super();
}
public String getProductName(String productID){
String productName = "No matching product found for ID : " + productID;

if (productID.equals("123")){
productName = "iPhone";
}
if (productID.equals("1234")){
productName = "iPod";
}
if (productID.equals("12345")){
productName = "iPad";
}

return productName;

}
}

I deploy to weblogic and test



I now register the service with OEG







Add a relative path



Test via Service Explorer



Now create a new Policy to process a REST version of this request
This request will have the format http://localhost:8082/ProductREST?productID=123





The first thing we need to do is parse the HTTP GET request and validate that the parameter is present (e.g. productID=123)





Now extract the productID value





Finish with a TRACE filter

Add a relative path



Deploy and test



Test via a browser -




You can ignore the error.

Check in Traffic Monitor



Now we need to compose this into a SOAP message for further processing

Add a SET Message Filter



We will set the message to the input from the Weblogic Web Service Tester



We just need to parameterize the productID





Add an HTTP Header for Content-Type



Add an HTTP header for SOAPAction





Set the HTTP Verb to POST





Now call the Product Service Policy



Deploy and test



No comments:

Post a Comment