users@jax-rpc.java.net

(wrong string) ç­å¤: Handler problems

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

Do you want the Handler to intercept the
request/response on the client machine/container, the
request/response on the server machine/container, or
both?

If its the client or both, you need code similair to
what you are doing.

If its the server/both, you need a configuartion file
that the web service itself uses during configuration.
In this case, you would _not_ call HandlerRegistry,
because its encapsulated from the client.

Keep in mind there are reasons to have a client/both
architecture, such as to digitally sign/encrypt the
data the client is sending to the web service, or log
all client traffic, etc.

iksrazal

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

> Hmm, I'm still lost. I've done like you said and
> used an wscompile
> client mode task with a config.xml as you said
> (handlerChains tags
> inside wsdl one)
> generated the static client code but still:
>
> Service_Impl f = new Service_Impl();
> HandlerRegistry r =
> f.getHandlerRegistry();
> Iterator ports = f.getPorts();
> while (ports.hasNext()) {
> QName e = (QName) ports.next();
> System.out.println(e.toString());
> List hc = r.getHandlerChain(e);
> System.out.println(hc.isEmpty());
> }
>
> returns "true". Sigh...
>
> On the other hand,
>
> Service_Impl f = new Service_Impl();
> HandlerRegistry registry =
> fact.getHandlerRegistry();
>
> HandlerInfo hi = new HandlerInfo();
> hi.setHandlerClass(foo.bar.Handler.class);
> hi.setHandlerConfig(hashtable);
>
> List hc = new ArrayList();
> hc.add(hi);
>
> Port_Stub stub = new ServerPort_Stub(new
> HandlerChainImpl(hc));
>
> TypeMappingRegistry types =
> fact.getTypeMappingRegistry();
> stub._initialize(new
> InternalTypeMappingRegistryImpl(types));
>
> works quite fine. Can it be that my handcrafted WSDL
> has wrong
> namespaces lying around and this breaks the code in
> the generated
> Service_Impl() factory class that does the same
> things I stated
> explicitly in my snippet?
>
> public foo.bar.ServerPort getPort() {
> String[] roles = new String[] {};
> HandlerChainImpl handlerChain = new
> HandlerChainImpl
>
(getHandlerRegistry().getHandlerChain(ns1_ServerPort_QNAME));
> handlerChain.setRoles(roles);
> foo.bar..Port_Stub stub = new
> foo.bar.Port_Stub(handlerChain);
> try {
>
> stub._initialize(super.internalTypeRegistry);
> } catch (JAXRPCException e) {
> throw e;
> } catch (Exception e) {
> throw new
> JAXRPCException(e.getMessage(), e);
> }
> return stub;
> }
>
>
>
>
> Il giorno 06/giu/05, alle ore 15:16, zhanglin ha
> scritto:
>
> > Put your handler class in the server side, and
> write a config.xml:
> >
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <configuration
>
xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
> >
> > <wsdl location="HelloWorld.wsdl"
> packageName="hello">
> >
> > <handlerChains>
> >
> > <chain runAt="client">
> >
> > <handler
> > className="ClientHandler">
> >
> >
> <property
> > name="ClientHandler" value="hello client handler"
> />
> >
> > </handler>
> >
> > </chain>
> >
> > </handlerChains>
> >
> > </wsdl>
> >
> > </configuration>
> >
> >
> >
> > When you generate the stub class with the WSDL
> file, use wscompile
> > with this config.xml.
> >
> > In the client side, you needn’t write the handler
> code, just write
> > your code as there is no handler, and you should
> get it working as
> > you wish.
> >
> > Good luck!
> >
> >
> >
> > -----------------------------------
> >
> > Regards!
> >
> >
> >
> > ZhangLin
> > Institute of Computer Software
> > Nanjing University
> > 210093
>



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