11 Aug 2013

Netbeans and APEX Rest Services

I've recently been playing with the RESTful services that you can easily generate in APEX.

I've set up Apache and Glassfish along with APEX Listener to expose them for use in Apps. I could document that, but it's easy enough to achieve. It could always be improved, but for now, I can at least see my web services.

By the way, to test my REST services, I am using https://apigee.com/console/others. The console there makes it really easy to enter your URL and test with header or body attributes.

Anyway, I decided to try to use Netbeans (7.3.1) to create some simple html5 apps that will use my REST services.
I ran into a small problem though. When registering my webservice, 

....I got the following error:
Cannot determine if the service is of type WSDL or WADL

I couldn't find a single reference to WADL and Oracle APEX anywhere.
So, I looked up WADL and how to write one. Perhaps, a WADL could sit anywhere, and just reference my REST services.

Firstly, my (simplified) REST web service.

This one has one module (the blue world), two templates, each with its own handler.

On my webserver, I have created a WADL to describe the module, the templates and its handlers:

<application xmlns="http://wadl.dev.java.net/2009/02">
 <resources base="http://myresturl:port/apexworkspace/module">
  <resource path="template1">
    <method name="GET"/>
  </resource>
  <resource path="template2">
    <method name="POST"/>
  </resource>
 </resources>
</application>

The "base" is the url that points to my REST services (being served by APEX Listener)
There is a resource element for each template, and within that a method which references the handlers.

Save that as a WADL and deploy to your webserver.

Now, when you add the resource to Netbeans, simply add the URL of the WADL rather than the services themselves.

In Netbeans, you should see your services:

I've not used the services in an App yet. Once I've got that done, I'll add the solution here.