How to Parse a RSS Feed in Java

A while back I was required to parse an rss feed on my company’s website.  Having little experience with Java Tag Libraries (.tld), I decided to give one a try.  The following is how I implemented RSS into a JSP page.

Import and include the tag library into your project.

In this case it is rssutils.tld and rssutils.jar.  This can be achieved many different ways either in the XML configuration or in the GUI Editor’s Import function (i.e. File > Import or Tools > Manage Libraries) etc.

Call Web Service in Java

Consume a Web Service with Java

As I stated before, calling a web service in .Net is easy .  However, using a Java Web Service is a little more difficult .  This is not because .Net is superior to Java, but instead because of the various standards that Java allows for since it is open sourced.  In other words, Java can be extended and new standards can be developed, whereas Microsoft keeps tight control over their beloved .Net framework.

Step 1:  Download and Install NetBeans

First you must download and Java IDE such as Netbeans , Eclipse , or Oracle’s JDeveloper .  I have used all three and I would recommend NetBeans because I found that JDeveloper was a little behind on certian standards and Eclipse requires that you install additional plugins to allow you to develop with web services.  However, the latest version of NetBeans (6.5 as of this writing) comes with everything you need to develop and consume web services, including a choice of embedded web servers for development.

Step 2: Create a Web Project and Web Service Client

Next, create a new Web Project by clicking File > New and selecting Web Project from the list.

Once it builds your project, you must tell NetBeans what type of project you are developing.  You can do this by right clicking your newly created Project in the Projects pane and selecting New > Web Service Client .  If I remember correctly, this is where a wizard will prompt you for the Web Service WSDL that you are wanting to call .

WSDL stands for Web Service Definition Language and is a document that is generated when you build a web service to tell the applications that want to use it what methods are available to use.

Step 3: Call Web Service

Once your project finishes generating the local methods for calling the external web service, you should see a tree option under your project entitled Source Packages . Open this tree item and all items below it and you should see a Java file "*.java"Double click this so it opens, then right click > Web Service Client Resources > Call Web Service Operation .

Step 4: Modify and Test

Once the generation is completed, you should be able to reference the web service objects similar to the following:

WsNameOfService port =   service.getWsNameOfServicePort();
boolean tf;
tf = port.isReady();

out.println("Result: " + tf);

Enjoy and Good Luck!

Note: If your not getting the same menu items as me then you probably created the wrong project type in the first couple of steps.  For instance, NetBeans may not allow you to create a Web Service Client in a regular Java project.  Start over with a new project and ensure you are selecting the correct project types.

.Net Consume Web Service

Consume Web Service with .Net

During the past 8 months, I have been playing with web services quite a bit – both calling and developing web services for my employer.  However, I had some trouble along the way finding information on the different standards of web services (such as JAX-WS and JAX-RPC ), implementing those web services on the server (Jboss) , and testing the services by writing a web service client (VB.Net) .

So I thought documenting the information I have collected would be useful for others attempting the same thing.  The next series of posts will show you how to write, deploy, and consume web services using a combination of .Net and Java.

Consume a Web Service in .NET

Calling a web service in Microsoft .Net framework is super easy.  Simply open a new or existing project, click Project > Add Web Reference , then enter the URL to the web service’s WSDL .

A WSDL is an XML document that is used to define a web service , such as Method Names and Parameters for those Methods.  Don’t worry, you usually don’t have to write this document by hand.  Yes, the programming gods have smiled upon us.  Most IDE editors will do this for you including Visual Studio and NetBeans .

After entering the URL as suggested above, just follow the wizard steps and .Net will take care of the rest for you.

Once complete, you should see Web References in the Solution Explorer pane in Visual Studio.  You can edit the Reference Name and URL in the Properties pane by clicking on the web service reference (whatever you named it) under Web References .

Now you can reference the web service object that you just created by typing "WhateverYouNamedIt. "

Go ahead and give it a shot!