aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes configuring handlers programmatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "configuring handlers programmatically " Watch "configuring handlers programmatically " New topic
Author

configuring handlers programmatically

michael warren
Ranch Hand

Joined: Oct 20, 2006
Posts: 50
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

Joined: Oct 20, 2006
Posts: 50
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

Joined: Oct 20, 2006
Posts: 50
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

Joined: Apr 29, 2001
Posts: 96
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 ]

SUN Certified Business Component Developer Java EE Platform 5 (2008)<br />SUN Certified Developer for Java Web Services (2007)<br />IBM WebSphere Portal V5.1 Application Development (2006)<br />SUN Certified Web Component Developer (2001)<br />SUN Certified Java 2 Programmer (2001)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42283
    
  64
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?


Ping & DNS - my free Android networking tools app
michael warren
Ranch Hand

Joined: Oct 20, 2006
Posts: 50
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: configuring handlers programmatically