PUT curl for RESTful Web Services with Oracle WebLogic Server and NetBeans IDE

It’s been a while since I worked with Oracle WebLogic Server and with the latest release of NetBeans IDE 7.2 RC1 I thought I’d give it a go again. As a matter of fact, the decision has greatly been influenced by being able to run it on Mac OS X. I don’t have to run a virtual environment whatsoever, be it VMware Fusion or Parallels, to have it up and running, and hence it substantially reduced the entry point. I was in.

I started with the Zip distribution for Mac OSX, Windows and Linux and after a couple of minutes I’ve got Oracle WebLogic Server installed. NetBeans IDE was also a no-brainer. I registered the server in the IDE and with the REST: Hello World (Java EE 6) sample I had all I needed to get started. I think a quarter was the time it took me to have it all ready (excluding download time).

The sample required no changes to run on WebLogic and was useful as the first step. It just worked.

What was interesting about the sample project was the way the HelloWorldResource worked. It handles GET and PUT with text/html for the former whilst text/plain for the latter.

GET‘ing the resource was straightforward – http://localhost:7001/HelloWorld/resources/helloWorld, but PUT required a bit different approach – I picked cURL.

$ curl -i -H "Content-Type: text/plain" -X PUT -d "Jacek" http://localhost:7001/HelloWorld/resources/helloWorld
HTTP/1.1 204 No Content
Date: Mon, 09 Jul 2012 08:11:25 GMT
Content-Length: 0
X-Powered-By: Servlet/3.0 JSP/2.2

I had never used curl with PUT before so it took me a while to have figured out how to pass the input parameter. With it sorted out (the -d command-line parameter), I also had to add -H "Content-Type: text/plain" and be ready for testing. It works fine now and refreshing the browser gives me a changed output.

On to reading Oracle WebLogic Server 11g Administration Handbook from Oracle Press. After a couple of pages, it seems lived up to my expectations.

Be Sociable, Share!
This entry was posted in Java EE, Tools, WebLogic.

Leave a Reply

%d bloggers like this: