• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

configuring handlers programmatically

 
michael warren
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read in different places that its possible to configure handlers programmatically, but the examples given always seem to be of using a deployment descriptor - has anyone got any examples of doing it programmatically ?

I'm thinking of the case where I want to add a handler to a static stub client.
 
michael warren
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually I think Watch's notes may have answered my question - just looking into it, somethin like
HandlerInfo class's setHandlerClass(),

EDIT:found the answer here
http://forum.java.sun.com/thread.jspa?threadID=306483&messageID=1223045
[ April 25, 2007: Message edited by: michael warren ]
 
michael warren
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just in case anyone is interested I struggled to get this working due to not being sure what QName for the portName to pass to the HandlerRegistry getHandlerChain method.

I decompiled the SwearerIF_Stub class that had been created earlier to find the line


guess I could have worked this out from my mapping file - or from combination of wsdl and the config file used to create client - but without knowing exactly whats required it would have been difficult, seems to be poorly documented to me.

The contents and mapping of what is in the WSDL is something thats on my list of stuff to revise anyway, so perhaps it will make more sense after I've done that.

Anyway this is the code that works for me
 
ruijin yang
Ranch Hand
Posts: 96
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by michael warren:
Just in case anyone is interested I struggled to get this working due to not being sure what QName for the portName to pass to the HandlerRegistry getHandlerChain method.


Hi,

I come to feel you are very confused about Handler. In fact, there are two kinds of handler. Both are needed to declare in the xml configuation files. One is in the client side, this needs to declare in web.xml:
<service-ref>
<description>WSDL Service AttachmentIBMService</description>
<service-ref-name>service/AttachmentIBMService</service-ref-name>
<service-interface>ibm.attachment.AttachmentIBMService</service-interface>
<wsdl-file>WEB-INF/wsdl/AttachmentIBM.wsdl</wsdl-file>
<jaxrpc-mapping-file>WEB-INF/AttachmentIBM_mapping.xml</jaxrpc-mapping-file>
<service-qname xmlns fx="urn:attachment.ibm">pfx:AttachmentIBMService</service-qname>
<port-component-ref>
<service-endpoint-interface>ibm.attachment.AttachmentIBM</service-endpoint-interface>
</port-component-ref>
<handler>
<handler-name>ibm.attachment.handler.AttachmentIBMClientHandler</handler-name>
<handler-class>ibm.attachment.handler.AttachmentIBMClientHandler</handler-class>
</handler>
</service-ref>

Another is in the server side, this need to declare in webservices.xml:
<port-component>
<port-component-name>AttachmentIBM</port-component-name>
<wsdl-port xmlns fx="urn:attachment.ibm">
pfx:AttachmentIBM
</wsdl-port>
<service-endpoint-interface>
ibm.attachment.AttachmentIBM
</service-endpoint-interface>
<service-impl-bean>
<servlet-link>
ibm_attachment_AttachmentIBMBindingImpl
</servlet-link>
</service-impl-bean>
<handler>
<handler-name>ibm.attachment.handler.AttachmentIBMHandler</handler-name>
<handler-class>ibm.attachment.handler.AttachmentIBMHandler</handler-class>
</handler>
</port-component>

Hope this help. If there is any error, please correct me because I am preparing for this exam too.
[ April 29, 2007: Message edited by: ruijin yang ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I come to feel you are very confused about Handler. In fact, there are two kinds of handler. Both are needed to declare in the xml configuation files.


Michaels point was that he didn't want to declare handlers outside of the code, but instead add them programmatically.

Am I correct in assuming that these config files you show work for WebSphere only?
 
michael warren
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf's right - I was trying to get handlers working for standalaone clients that weren't part of a web application - so needed to do it programatically - as configuration in web.xml wasn't relevant.

I got it working as explained in my reply above, although I've seen so little reference to doing it programatically that I think its probably something you don't need to worry too much about for the exam.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic