You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Gerald Turner <gt...@unzane.com> on 2011/12/08 23:24:49 UTC

Embedded axis2

Hello, I have a project requiring a WAR containing a build-time
generated SOAP client to be deployed on an old J2EE application server
running Java 1.5 with clean classloader isolation.

This is my first SOAP client that requires the WS-Security extension so
I figured I'd try Axis2 with Rampart.

In the distant past I had used Axis 1.4, it worked well: WEB-INF/lib
would contain a single axis-1.4.jar accompanied by three javax.*
JSR-type jars with funny names that were included (polluted?) in the
Axis1 distribution, and a small handful of Jakarta commons jars that I
mostly use with or without Axis anyway.  These projects built with Ant
and the custom wsdl2java taskdef to do the code generation.  The code
invoking the client stub didn't import any org.apache.axis.* or any
SOAP-related javax.* packages.  It simply instantiated the
code-generated “locator” (with overridden URL in the constructor).

I'm entirely confused about whether Axis2 (with Rampart) can be embedded
this way.  Haven't found any examples.  Initial testing suggests it may
be possible (e.g. I've gotten an Axis2 client stub to invoke, just
without the Rampart/WS-Security part).

Here's a piece of the initialization code.  Somebody please let me know
if I'm going about this wrong, should give up and have go about with a
traditional Axis2 “install”.

    ConfigurationContext context =
      ConfigurationContextFactory
        .createConfigurationContextFromFileSystem(null, null);

  ¹ URL rampartURL = getClass().getResource("/axis2/rampart-1.6.1.mar");
    File rampartFile = new File(rampartURL.getFile());

    AxisConfiguration guts = context.getAxisConfiguration();
    AxisModule module = DeploymentEngine.buildModule(rampartFile, guts);
    guts.addModule(module);

  ² this.service = new Import_IVR_TransactionStub(context, this.url);

    ServiceClient client = service._getServiceClient();
  ³ client.engageModule("rampart");
    Options options = client.getOptions();
    options.setUserName(this.username);
    options.setPassword(this.password);

¹ My build script stuffs the MAR file in WEB-INF/classes/axis2

² Pardon the ugly generated class name, the WSDL I'm working on is one
  of the worst I've ever seen.  This client gets *a lot* uglier further
  on when it does an invocation.  This brings up another question, with
  JAX-WS I'm able to write “binding” files to cleanup the WSDL barf and
  make Java look pretty - Axis2 have anything like that?

³ This line throws “AxisFault: Unable to engage module : rampart” without
  a chained exception to debug.  If I comment this line out the stub
  actually functions well even though I've jiggered the guts of Axis2.
  Also prior to the exception I get a weird System.err message
  “TempFileManager::unable to delete /tmp/axis2-tmp-4251.tmp”, and sure
  enough there's a bunch of dirt in /tmp including what look like lock
  files from previous deployments.

-- 
Gerald Turner   Email: gturner@unzane.com   JID: gturner@unzane.com
GPG: 0xFA8CD6D5  21D9 B2E8 7FE7 F19E 5F7D  4D0C 3FA0 810F FA8C D6D5