Hello Werner,
The way I described to register handlers on the client side is the
JAX-RPC 1.1 compliant way. It works on Axis 1.x and any other JAX-RPC
1.1 compliant SOAP engine.
However, it requires you to use the interfaces in javax.xml.rpc. I do
not know what would happen if you mix it with Axis' org.apache.axis classes.
If you do not care about JAX-RPC compliance and do not mind a direct
dependence on Axis code, read Rodrigo's replies. I am not familiar with
that way, but it should work too.
> This is my code (service is an instance of
> org.apache.axis.client.Service, Loghandler is
> org.apache.axis.handlers.LogHandler, the rest is like you wrote it):
Can you try using the javax.xml.rpc equivalents?
Refer also to the following example:
axis-1_3\samples\jaxrpc\hello
Hope that helps!
Regards,
Dies
Jansen Werner wrote:
Good morning Dies,
thanks for your help! I tried what you wrote and couldn't get it
working.
This is my code (service is an instance of
org.apache.axis.client.Service, Loghandler is
org.apache.axis.handlers.LogHandler, the rest is like you wrote it):
private static void registerHandlers(Service service)
{
HandlerRegistry hr = service.getHandlerRegistry();
List<HandlerInfo> hl = new ArrayList<HandlerInfo>();
hl.add(new HandlerInfo(LogHandler.class, null, null));
hr.setHandlerChain(new QName(
"http://www.eon-is.com/namespaces/soap/1.0", "log"),
hl);
}
service is initialized using its default constructor before calling
registerHandlers (Service service = new Service();). After calling
registerHandlers and registerTypeMappings (adding Classes, Serializers
and so on), this instance is used to create a call (call = (Call)
service.createCall();) that is filled with parameters, values, endpoint,
... and then executed.
When I run my SOAP call that calls registerHandlers before executing,
nothing happens. At least nothing different from when the Handler was
not included. What did I do wrong? If there's any information needed for
further help, let me know. I'm stuck, I feel like finding lost contact
lenses in a dark alley if you had quite a few beers. Not that I know how
this feels like, but it must be similar to this :)
Greetings from Munich,
Werner
-----Original Message-----
Sent: Tuesday, July 04, 2006 1:55 AM
To: [email protected]
Subject: Re: Adding own handler in Java Code?
Hello Werner,
Refer to the JAX-RPC1.1 spec to see how to use a client handler in a
portable way. I believe it goes something like this:
sf = javax.xml.rpc.ServiceFactory.newInstance();
SEIService si = (SEIService)sf.loadService(SEIService.class);
// register client handler
javax.xml.rpc.handler.HandlerRegistry hr = si.getHandlerRegistry();
java.util.List hl = new java.util.ArrayList();
hl.add(new
javax.xml.rpc.handler.HandlerInfo(YourHandler.class,null,null));
hr.setHandlerChain(new
QName("http://localhost/xxx/","yourPort"),hl);
SEI sei = si.getSEIPort();
YourHandler should implement javax.xml.rpc.handler.Handler.
I don't know whether the LogHandler you are referring to is a JAX-RPC
compliant one..
Hope that helps,
Dies
Jansen Werner wrote:
If you mean "selecting a subset among an already well-known set of
available handlers", the answer is that it is easier :-)
You will have to create a handler that could act as a
"handler chain",
and put into it the logic to take the decision about what
handlers to
actually call when invoked. Depending on what you need,
this handler
will have the information needed to find out the handlers to
call (for
example, by parsing a policy), or you may have to include the
mechanisms
to communicate with it from the service implementations or
other points,
and configure it at runtime.
OK, this sounds like my problem.
For an example, let's take the LogHandler packaged with
axis. How can I
add this (simple, easy) Handler to Axis at runtime? (And
remove it later
...).
I have found a way to access the HandlerRegistry
(Service.getHandlerRegistry()). But - without deeper
knowledge of the
HandlerChains available - how do I add my Handler (or the LogHandler
mentioned above)?
Just keep in mind that you need to respect the handlers
interface, and
call their methods in the appropriate order. That is, to
initialise them
before invoking them, and the like.
This is something I will concentrate on when I managed to add the
LogHandler provided by Axis :)
Ah, before I forget it again, our Axis version is 1.3 :)
Thanks in advance :)
CU
Werner
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]