views:

345

answers:

1

I'm using Apache Axis 1.4 (yes, the old one), with wsdl2java to generate the client code for a webservice. I'd like to set additional properties on the Call object before calling methods on the generated stub.

For example, I'd like to set username, password, perhaps add or modify existing headers, and change the client handlers to use different implementations.

Currently, I'm doing this by modifying the generated Stub class and calling the appropriate setters. However, I'd like to achieve this without touching the generated files. I"m confused, though, because the Stub class has:

createCall()

which creates the call object and sets some properties. Currently, this is where I'm modifying the generated source code; then, the Stub contains:

clientMethod1(){
    blahblah
    Call _call = createCall();
    ......
    _call.invoke();
}

So I can't see a way that I can use the serviceLocator to get a stub, modify the properties I want to modify, and then use the stub to call the methods I want to call, given that the stub methods call createCall() and then call invoke. There doesn't appear to be a way to intercept the new Call object before it's invoked.

So: How do you modify properties in the call without modifying the generated Stub class's source code?

Thanks for info or even pointers to existing documentation.

A: 

I wouldn't like to touch the generated code too. The risk is that I once have to regenerate it and loose my edits.

Without knowing axis details - isn't it possible to subclass the Stub and override 'createCall'? Axis won't touch this subclass and you could set your properties in the overridden createCall method

Andreas_D
Andreas, good thought. I could do as you suggest. However, I think the one drawback is that then I'd have to instantiate the stub directly, which is "frowned upon" in Axis. Generally, you get the stub from the "ServiceLocator". And it does some hocum, then returns the stub. I've always wondered just how much value the servicelocator offers, though. Perhaps it's time to explore that, and potentially just instantiate a subclass, as you suggest.
marc esher