users@jax-rpc.java.net

答复: Handler problems

From: zhanglin <zhanglin_at_ics.nju.edu.cn>
Date: Mon, 6 Jun 2005 21:16:56 +0800

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

  _____

发件人: Edoardo Causarano [mailto:curious.corn_at_katamail.com]
发送时间: 2005年6月6日 17:30
收件人: users_at_jax-rpc.dev.java.net
主题: Handler problems

 

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>
http://localhost:8081/service/server");

port = (ServerPort) pstub;

HandlerRegistry registry = fact.getHandlerRegistry();

List hc = registry.getHandlerChain(

new QName(" <http://localhost:8081/service/server>
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