A Home Made Eclipse CXF Plugin

I’d been looking around for web service stacks to use in a recent web service implementation I had. I read about both Apache Axis2 and CXF, but for various reasons I felt drawn to CXF.

Unfortunately, I realised that there was no web service runtime plugin for CXF as there is for Axis2. If you are just like me in this predicament, don’t give up just yet. I recently came across a way to get what I wanted, though not in as beautiful a solution as I’d have wanted. And the solution? Use, Eclipse’s External Tool Configurations. Here’s how you could also solve the problem.

  1. Create a new Java project named cxfclient.

  2. Copy the wsdl file to the src folder of the project.

  3. In the Eclipse menu, select Run → External Tools → External Tools Configuration.

  4. Click the “New launch Configuration” icon at the top of the left column. A “New_configuration” configuration is created.

  5. In the name field, provide the word “wsdl2java” as the name of the configuration.

  6. In the “Main” tab, provided the following values in the respective fields

    1. Location – Click “Browse File System” and navigate to the location where your cxf download is extracted to.

    2. Working directory – Click “Browse Workspace” which should show the list of projects in your Eclipse workspace. Select the “src” folder of your project, since the generated classes will be put there, and your wsdl file is also located there.

    3. Arguments – The only argument that we will provide in this process is the name of the WSDL file, in this case Calculator.wsdl. However, this is where any extra parameters can be passed to wsdl2java to tweak its behaviour. For example, to generate a consumer of the Calculator service, specify “-client” before the name of the wsdl file.

  7. Click the “Refresh” tab and check the “Refresh resources upon completion”.

  8. Click “Apply” to make all these changes permanent.

  9. Click “Run” to see your generated implementations of the Calculator service. Your configuration should look like this.

You can apply this trick to add any tool that is not yet integrated into Eclipse but has command line tools to work with. Enjoy tweaking.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s