Enterprise Integration Zone is brought to you in partnership with:

Ryan has posted 17 posts at DZone. You can read more from them at their website. View Full User Profile

JAX-RPC client with Maven2

  • submit to reddit

Recently I needed to make my Maven2 web project communicate with an old style RPC encoded web service. We run on GlassFish which comes with JAX-RPC RI built-in, so I was hoping to find a way to use it without having to bundle another runtime such as Axis into the project. Specifically I was looking for a way to make my build-script generate client stubs from a WSDL file in the project tree. I want the client stubs to use standardized JAX-RPC APIs which are serviced by the implementation provided by GlassFish.

I found that the JAX-WS RI has a Maven2 plugin but not the JAX-RPC RI. I did a lot of googling, and posted messages in a few mailing lists. Surprisingly there is almost nobody using JAX-RPC on Maven2 projects because there are barely any examples online and nobody could answer my question. I'm surprised because there are a lot of legacy systems out there that developers need to integrate with, so I can't be the only one still needing JAX-RPC support. Some people suggested that I update the web service to modern RPC literal to make client-side development easier with JAX-WS, but that is not an option. Others suggested that I use Maven's antrun plugin to call out to an ant build script that does JAX-RPC work. Finally I found an all Maven solution that works for me:


private MyServiceSEI getMyServicePort() throws ServiceException {
MyServiceLocator locator = new MyServiceLocator();
MyServiceSEI port;
Stub stub;

port = locator.getMyServiceSEIPort();

// OPTIONALLY configure URL and HTTP BASIC authentication
stub = (Stub) port;
stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://hostname/ContextRoot/ServicePort");
stub._setProperty(Stub.USERNAME_PROPERTY, "user");
stub._setProperty(Stub.PASSWORD_PROPERTY, "secret");

return port;


It works, but I think the client stubs are dependent on the Axis 1 runtime instead of using the GlassFish provided JAX-RPC runtime through the standardized JAX-RPC APIs. I've wasted enough time on this so I moved on. If you know a better way to do this, please let me know. No RESTful services rants please! I think SOAP and REST both have their uses depending on what you are doing. From my perspective, JAX-WS SOAP development is effortless and requires significantly less code than REST because I don't have to write the building/parsing code. After examining raw SOAP messages without extra WS-* headers added in, I decided that overhead is not a valid argument against SOAP. When you need more advanced features they are available to you without having to re-invent the wheel. I think most Java developers' negative impressions on SOAP comes from the JAX-RPC and Axis days, and because they haven't tried JAX-WS yet.

From http://www.ryandelaplante.com/

Your rating: None
Published at DZone with permission of its author, Ryan Developer.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Tin Blaskovic replied on Wed, 2011/07/13 - 3:05am

There is now a jaxrpc-maven plugin in active development (at the time of this writing), at http://sf.net/projects/jaxrpc-maven

Ryan Developer replied on Sat, 2012/01/14 - 1:16am

On my original blog post someone posted a comment with another possible solution:

com.sun.xml.rpc:1.1.3_01 (exclusion: javax.activation:activation)

repositories:http://download.java.net/maven/2/ (layout: default) and 
http://download.java.net/maven/1 (layout: legacy)

Then use the maven-antrun-plugin to run wscompile
<taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile">
    <classpath refid="maven.compile.classpath" />

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.