X

Geertjan's Blog

  • January 11, 2008

Web Service Vendor Framework

Geertjan Wielenga
Product Manager
One of the most hidden features of NetBeans IDE 6.0 is... a framework for web service providers to integrate their web services into the IDE. To understand what that means, look at this screenshot:

I added the Daily Dilbert web service from eSynaps to the palette. (The other ones you see above are there by default.) The palette only contains these web service items if (1) you have the RESTful Web Service plugin installed and (2) an appropriate REST resource class is open in the editor.

How did I get that Dilbert web service item into the palette? Many many NetBeans API classes? Much digging through code? Pulling of hair from head? No. I looked at the WSDL file that defines the Daily Dilbert web service. Then I created an XML file with exactly this content (using the information gleaned from the three links I provided in yesterday's blog entry):

<?xml version="1.0" encoding="UTF-8"?>
<component
xmlns="http://xml.netbeans.org/websvc/rest/component/1.0"
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation='http://xml.netbeans.org/websvc/rest/component/1.0
../../../../../../../../../../rest/src/org/netbeans/modules/websvc/rest/component/component.xsd'
name="DailyDiblert"
category="/Esynaps"
nameKey="DailyDilbert_Desc"
categoryKey="Esynaps"
bundle="com.esynaps.services.nbcomponents.Bundle">
<description key="DailyDilbert_Desc"
bundle="com.esynaps.services.nbcomponents.Bundle"/>
<icons>
<icon url="com/esynaps/services/nbcomponents/dilbert-16.png" size="16"/>
<icon url="com/esynaps/services/nbcomponents/dilbert-32.png" size="32"/>
</icons>
<service name="DailyDilbert">
<method name="DailyDilbertImagePath"
serviceName="DailyDilbert" portName="DailyDilbertSoap"
type="http://schemas.xmlsoap.org/wsdl/"
url="http://www.esynaps.com/WebServices/DailyDiblert.asmx?WSDL">
<documentation>
This operation provides a path to a Daily Dilbert image.
</documentation>
</method>
</service>
</component>

I created a new module project, put the above XML file into the module source structure, and then registered it in the layer file like this:

<folder name="RestComponents">
<folder name="Esynaps">
<file name="DailyDiblert.xml" url="DailyDiblert.xml"/>
</folder>
</folder>

And that's all. I needed to restart the IDE, and then the Dilbert item was in the palette. Now, what does that item do for me? When I drag it into a resource class, I see the following:

There are no parameters that need to be filled in for the Daily Dilbert service, hence no parameters in the dialog above. ("Wait a minute!", you should now be thinking. "When did you create that dialog?" And the answer is: I didn't. I only provided a module with the XML definition above and the layer registration. The framework provided under the hood by the IDE does the rest.)

What happens when I click OK? A new resource class, called DailyDilbertResource is created. Plus, in the class where I dropped the item, a small stub method is created, for retrieving the resource:

/\*\*
\* Returns DailyDilbertResource sub-resource.
\*/
@UriTemplate("dailyDilbert/")
public DailyDilbertResource getDailyDilbert(@UriParam("customerId")
Integer id) {
try {
return new DailyDilbertResource();
} finally {
PersistenceService.getInstance().close();
}
}

Next, I discovered that I could use the "Test RESTful Web Services" functionality, to try out my Daily Dilbert integration in the IDE:

This is all pretty cool. What is missing here, of course, is a wizard. The vendor should be able to create a module project and then use an "apisupport" wizard (i.e., a wizard from "Module Development" in the New File wizard) to simply choose a WSDL file. The wizard would then extract the necessary information, create the XML file, and register it in the layer. Once we have that, vendors will be able to integrate their web services in the IDE while drinking their coffee on a Monday morning while still recovering from the weekend. In other words, without needing to think.

Join the discussion

Comments ( 9 )
  • Casper Friday, January 11, 2008

    That's sweet. I could be wrong, but it strikes me as being a more appropriate KISS way to go within SOA, having been drowned before in Oracle's mega-complex SOA frameworks/tools/stacks.

    What would be really nice is if companies could run their own NetBeans update center (cascading on the official ones, a kin to Maven) and push out new service components which would automatically show up in the palette for all developers. This could be done for other components too of course, Swing, JSF etc.


  • Geertjan Sunday, January 13, 2008

    Thanks Casper, I like this too. And your 'push' idea is interesting.


  • guest Wednesday, January 16, 2008

    jhjhg


  • Thomas G Henry Sunday, February 17, 2008

    How can I do something like this for RememberTheMilk? I can't seem to get at their WSDL and I think they don't have one.

    http://api.rememberthemilk.com/services/rest/

    This is their API endpoint. I have an API key and I can get responses for at least the echo method (in FireFox), but I'm not sure how to do anything with this in NetBeans.

    I'm new to this. :)

    Thanks!

    Tom


  • Geertjan Sunday, February 17, 2008

    Hi Tom. Exploring this now and I will hopefully blog about it today.


  • Thomas G Henry Monday, February 18, 2008

    Excellent! Thanks. I look forward to seeing what you come up with.


  • Geertjan Monday, February 18, 2008

    Thomas, they don't seem to have made a WSDL available, so there's nothing I can do to integrate with them. They seem to have a Java API in the works, but I don't know anything other than that.


  • Thomas G Henry Monday, February 18, 2008

    That explains it.

    Thanks, anyway.

    Keep up the good work!


  • Lukas Jungmann Friday, May 30, 2008

    I tried to show Remember The Milk at: http://blogs.sun.com/blog/entry/remember_the_milk ;-)


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.