答复: 答复: Handler problems

From: zhanglin <>
Date: Tue, 7 Jun 2005 10:16:52 +0800

I haven’t tried if I could get the handlerChain with this method, what I
got is that the handler does work. When you use the wscompile –gen:client
config.xml you could notice that some additional classes are generated.

Here is my client code


       String url = "";


       String namespace = "urn:HelloWorld/wsdl";


       String serviceName = "HelloWorld";

       QName serviceQN = new QName(namespace, serviceName);


       ServiceFactory serviceFactory = ServiceFactory.newInstance();

       Service service = serviceFactory.createService(new URL(url),


       Stub stub = createProxy();

       stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, url);


       hello.HelloWorldSEI hello = (hello.HelloWorldSEI)stub;






    public static Stub createProxy() {

        return (Stub) (new hello.HelloWorld_Impl().getHelloWorldSEIPort());



I did some print job when the service was called, and it worked. But I think
that this method can only be used for the static client, I don’t know how
to add a handler when use the dynamic proxy or the DII. If you find how to
do this, please tell me, thank you!





Institute of Computer Software
Nanjing University


发件人: Edoardo Causarano []
发送时间: 2005年6月7日 0:05
主题: Re: 答复: Handler problems


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);


                List hc = r.getHandlerChain(e);




returns "true". Sigh...


On the other hand,


Service_Impl f = new Service_Impl();

HandlerRegistry registry = fact.getHandlerRegistry();


HandlerInfo hi = new HandlerInfo();




List hc = new ArrayList();



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 getPort() {

   String[] roles = new String[] {};

   HandlerChainImpl handlerChain = new

   handlerChain.setRoles(roles); stub = new;

   try {


        } 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="">

         <wsdl location="HelloWorld.wsdl" packageName="hello">


                            <chain runAt="client">

                                     <handler className="ClientHandler">

name="ClientHandler" value="hello client handler" />







When you generate the stub class with the WSDL file, use wscompile with this

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!





Institute of Computer Software
Nanjing University