users@jax-rpc.java.net

Re: Handler problems

From: trebor iksrazal <iksrazal_at_yahoo.com>
Date: Mon, 6 Jun 2005 04:03:09 -0700 (PDT)

I've only used Handlers with Axis, but I use the
standard Java imports/interfaces from Sun so it should
be just about the same. And in this case I'm not using
WSDL/JWS.

    QName svcQName = new QName(endpoint,
nameSpaceUri);
    QName portQN = new QName(endpoint, pq);
    ServiceFactory sf = ServiceFactory.newInstance();
    Service svc = sf.createService(svcQName);
    HashMap handlerConfig;
    //Add host to HashMap sent to Handler
    handlerConfig.put("myvar",
Utils.getKeyAsString(invokeProps, "myvar"));
    //add ClientHandler to chain of events
    java.util.List list =
svc.getHandlerRegistry().getHandlerChain(portQN);
    list.add(new
javax.xml.rpc.handler.HandlerInfo(ClientHandler.class,this.handlerConfig,null));
    // Axis specific, adapt for Sun style:
    Call call = (Call) svc.createCall(portQN);
    ...

    So the 'handlerConfig' hashmap is for user defined
vars, read in the ClientHandler.class:

    public void init(HandlerInfo config)

As I recall, it does silently fail - in this case not
call the handler - if the port/qname/wsdl whatever, is
not exactly right. So I would debug liberally.

curious.corn, as from Ozric Tentacles?
iksrazal

--- Edoardo Causarano <curious.corn_at_katamail.com>
wrote:

> I can't get handlers to work; as far as I've
> understood this client
> code should init the handler class before the remote
> method call but
> nothing happens as far as handlers are concerned.
> I've looked around
> but there's nothing except boilerplate tutorials.
> Can anyone please
> give me a hint? Does changing the stub address break
> handler chains?
>
> Stub pstub = (Stub) port;
>
> pstub._setProperty(Stub.SESSION_MAINTAIN_PROPERTY,
> Boolean.TRUE);
>
> pstub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY,
> "http://localhost:8081/service/server");
> port = (ServerPort) pstub;
>
> HandlerRegistry registry =
> fact.getHandlerRegistry();
> List hc = registry.getHandlerChain(
> new
> QName("http://localhost:8081/service/server"));
> HandlerInfo hi = new HandlerInfo();
>
> hi.setHandlerClass(Handler.class);
> // populate the properties
> Hashtable hashtable = new Hashtable();
> hashtable.put("key", "value");
>
> // set the properties in handler
> hi.setHandlerConfig(hashtable);
> hc.add(hi);
>
> e
>
>



                
__________________________________
Discover Yahoo!
Have fun online with music videos, cool games, IM and more. Check it out!
http://discover.yahoo.com/online.html