Jungi's Blog...


Friday May 30, 2008

Remember The Milk

Some time ago Google point me to the Remember The Milk service which looks interesting although it definitely wasn't what I've been looking for. An interesting question which came into my mind was if and how this service could be integrated into the IDE.

There's already available some documentation which describes way how services could be integrated into NetBeans' REST palette, which has been replaced by Web Service Manager in NetBeans 6.1, see for example http://wiki.netbeans.org/CreatePartnerWebServiceModule, http://wiki.netbeans.org/RESTPartnerSvcRegistration or Geerjan's blog but none from these shows how to integrate some service with REST interface, like ie Remember The Milk, into the IDE. And "how" is really simple, just follow these steps:

  1. create some NetBeans module project
  2. write the WADL file
  3. write the XML schema (optional)
  4. write (well, just copy ;-)) templates for Authenticator and Service files
  5. write the saas-service description document
  6. tweak module's layer.xml file to contain correct reference to saas-service description
Simple, isn't it?

So for Remember The Milk service, which is similar to Flickr we need:

  1. create some NetBeans module project
  2. WADL file
  3. XML schema (will be added later)
  4. some templates, see sources
  5. write the saas-service description document
  6. module's layer.xml
and that's all, now module can be built, installed and used from the IDE.

Module sources are available here, nbm you can install into the IDE is here. Enjoy!

In the next part I'll try to show, how this service can be called and used from within the IDE

.

Wednesday Nov 08, 2006

tcpmon in NetBeans 5.5

tcpmon is a utility to monitor a TCP connection, authored by Inderjeet Singh and hosted on https://tcpmon.dev.java.net/ which runs in in standalone mode, as Java Web Start application and now also directly from NetBeans.[Read More]

Thursday Oct 19, 2006

Export EJB client jar in NetBeans 5.5 & 6.1

When packaging enterprise application it can be useful to have separated EJB remote and local interfaces from EJB implementation. The jar with EJB interfaces (aka ejb client jar) can be then packaged into the lib directory in the final ear archive to become automatically visible to all submodules. The ejb client jar is also useful in cases you want someone to call your beans but you don't want to give him implementation classes. In this entry I'll present simple NetBeans module for NetBeans 5.5/6.1 which is able to export ejb interfaces from existing ejb module project. I'll also show you a way how to do that as a part of build process if you don't want to use "just another module" for that.[Read More]

Friday Jul 28, 2006

Java EE application client on top of NetBeans Platform

This entry shows an idea how to create Java EE application client based on NetBeans Platform which we will deploy to and run on GlassFish. For simplicity FeedReader demo application which is bundled with NetBeans will be used for demonstration.[Read More]

Tuesday Jul 18, 2006

Securing Web Service (BASIC auth)

This entry is based on this example and shows how to configure a JAX-WS-based web service for HTTP BASIC authentication in Netbeans 5.5. The purpose of this is not to show how to create webservice but to show how to configure security on it, so just simple HelloService will be used.[Read More]

Friday Feb 03, 2006

NetBeans 5.0 & Web service client on JBoss

Today we will create JSR-109 (container generated) web service client for the web service from my previous post. And we will use JBoss again ;-)

Creating simple UI

Code of the form in index.jsp, nothing more to say here:


Source code of form in index.jsp

Creating the client

Again an easy step - use a wizard for it. Fill in values for wsdl url (should be smth like http://localhost:8080/JBossWebservice/CalcService?WSDL), package name (I will use math.calculator.client), press Retrieve button and Finish the wizard. The client will be generated by IDE.


Coding the servlet

Now we will create the heart of our simple application - servlet which will call our web service and show us the result of that call. First, we will create some helper methods - for retrieving parameter from HttpServletRequest and for showing instance of ComplexNumber in human-readable way:


Source code of helper methods in CalcServlet.java


Following picture shows possible implementation of processRequest method without ws invocation code:


Template for processRequest method in CalcServlet.java


Now use "Web Service Client Resources -> Call Web Service Operation" action from editor's context menu on emtpy lines in our code. This action will add necessary helper methods to our servlet and also the ws operation invocation code. Only thing we have to do is to modify generated code in processRequest method. The result can look like this:


Source code of the processRequest method's template in CalcServlet.java

Building and deploying project

This is the most important part if we want to be run this project on JBoss. As in previous case (ws creation) we have to create server-side artifacts manually - here's target for project’s build.xml (if the name of your service is not CalcService replace it with yourServiceName):


Build.xml<


And the last thing we have to do is to remove JAX-RPC library from the libraries which will be packaged with our application - we need this library only for building our project. So uncheck "package" checkbox in for JAX-RPC 1.6 library in Project properties -> Libraries.


Now we are ready to deploy and run our project. Let's see if it works (click on the picture for better view):


Build.xml


And here you can download sources for this project. Enjoy... :-)


Troubleshooting:

  • don't forget to set proxy if you are behind firewall - most problems are caused by this. In NetBeans there it can be configured in Tools -> Options. JBoss should be started with -Dhttp.proxyHost=yourProxyHost -Dhttp.proxyPort=yourProxyPort options (can be configured in $JBOSS_HOME/bin/run.{sh|bat}). If you are setting/changing proxy during working with project, it's better to recreate the websvc client because there's currently no way how to change proxy settings for the wscompile.
  • JBoss allows user to set address which will be used in deployed WSDL - it's always good to set it to fqdn, ip address or "localhost". You can set this in $JBOSS_HOME/server/default/deploy/jboss-ws4ee.sar/META-INF/jboss-service.xml under attributte "WebServiceHost".

NetBeans 5.0 & Web services on JBoss

Let’s create doc/lit web service which will provide two operations: plus and minus. Sounds easy? So do it for complex type and have JBoss as target server… ;-)

Required software

Coding ComplexNumber.java

Complex number consists of real and imaginary part, so we will create a value object for it. It will have two private fields, some getters and setters and two constructors. Full code:

Source code of ComplexNumber.java

Creating Web Service

Creating web service is also an easy step there’s a wizard for its creation and actions for adding operation to web service (you can find it in the editor’s and web service’s context menu). So here’s only listing of web service implementation:

Web service implementation

Building and deploying project

This is the most important part if we want to be able to use the service which will be deployed to JBoss – we have to create server-side artifacts manually but wscompile is our friend here :-) (see JBossWSFAQ). So let’s do it – add following target into project’s build.xml (if the name of your service is not CalcService replace it with _yourServiceName_ ):

Build.xml

Now we are ready to deploy our project and to test our web service. Let's see if it works (click on the picture for better view):

Build.xml

And here you can download sources for this project. Enjoy... :-)


Today's Page Hits: 2