Introducing a small but powerful PeopleSoft bolt-on that makes web services very easy. If you have a SQL statement, you can turn that into a web service in PeopleSoft in a few minutes.Read More & Purchase
This section is going to cover some code samples related to REST handlers.
There are time where you may need to create a Service Operation Handler that serves both REST and HTTP services. Most of the code in the handler might be the same between those two. The real difference is generally how you detect parameters. This can be useful when you do not want to duplicate code and you need to serve legacy and new clients. This section will not pertain to all readers in practice.
First let’s take a look at how we can determine at run-time if the service is running under a REST web service setup. You can call the
GetURIDocument() method on the Request
message object. If it throws and error then you know you are NOT running under REST and you can assume HTTP. Here is a code sample. You will see that we have a try/catch block. Often times, you will have a try/catch block wrapping your entire
onRequest handler which is NOT in this code sample. This “Is running under REST context” check needs to have it’s own nested try/catch block so it does not bubble up to the parent.
There are a few ways to structure your REST Services when you have multiple Methods:
When you have a single handler processing different HTTP Methods you are going to need to detect the HTTP Method at run-time and take the appropriate action. Here is a code sample that shows how to detect the HTTP Method.