Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: jaxws handler support in spring

  1. #1
    Join Date
    Jul 2005
    Posts
    156

    Default jaxws handler support in spring

    Hello,

    Is there some kind of jaxws handler support out of the box in spring ?

    I'm looking to configure a list of handlers by injecting some spring beans in the handlers.

    So perhaps a delegating handler (like org.springframework.web.filter.DelegatingFilterPro xy) which calls a CompositeHandler configured in Spring would do the trick.

    Thanks for your help !

  2. #2
    Join Date
    Jul 2005
    Posts
    156

    Default

    Ok, we've advanced a bit on the subject.

    Our need here is to configure WS-Security JAX-WS handler and an additional custom handler in spring configuration files.

    We're using JAX-WS2 on JEE5 (no Spring Web Services).

    With JEE5 specification, in order to configure server side JAX-WS handlers, we need to use @HandlerChain which links to a handler-chain file.
    The handler-chain file contains the list of jax-ws handlers which will be executed.

    The problem is we really want to configure our handlers in spring configuration, and not in this handler-chain.xml file.
    So, we have written a delegating handler (ServerDelegatingSoapHandler).
    The limitation of our handler is that it cannot be configured (we cannot configure handlers in the handler-chain.xml, this really sucks - perhaps we missed sthing on the spec, but I doubt it).

    For instance :
    . service implementation :
    Code:
    @javax.jws.WebService (blabla)
    @HandlerChain(file="handler-chain.xml")
    public class PortefeuilleService1SOAPImpl extends SpringBeanAutowiringSupport{
    . sample handler-chain.xml file
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <javaee:handler-chains xmlns:javaee="http://java.sun.com/xml/ns/javaee"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <javaee:handler-chain>
            <javaee:handler>
                <javaee:handler-class>
    com.blabla.integration.remoting.jaxws.handler.ServerDelegatingSoapHandler
                </javaee:handler-class>
            </javaee:handler>
        </javaee:handler-chain>
    </javaee:handler-chains>
    And spring configuration file (ServerDelegatingSoapHandler always call handler chain with name serverHandlers) :
    Code:
    <util:list id="serverHandlers">
        <bean class="com.blabla.integration.remoting.jaxws.handler.security.wss4j.ServerWss4jHandler">
            <property name="wss4jSecurityInterceptor" ref="wss4jSecurityInterceptor"/>
        </bean>
        <bean class="com.blabla.integration.remoting.jaxws.handler.context.ServerExecutionContextSoapHandler"/>
    </util:list>
    
    <bean id="wss4jSecurityInterceptor" class="com.blabla.integration.remoting.jaxws.handler.security.wss4j.Wss4jSecurityInterceptor">
        <property name="validationActions" value="UsernameToken "/>
          <property name="securementActions" value="UsernameToken"/>
        <property name="securementUsername" value="pipo"/>
        <property name="securementPassword" value="bimbo"/>
          <property name="validationCallbackHandler">
              <bean class="com.blabla.integration.remoting.jaxws.handler.security.wss4j.callback.SimplePasswordValidationCallbackHandler">
                <property name="users">
                    <props>
                        <prop key="Bert">Ernie</prop>
                        <prop key="pipo">bimbo</prop>
                    </props>
                </property>
              </bean>
          </property>
    </bean>
    So, once more this configuration works, but :

    • the developer needs to know ServerDelegatingSoapHandler always call a handler chain with id serverHandlers. This is a bit 'magical'.
    • the class ServerDelegatingSoapHandleralways call the same handler chain. If we need to have multiple handler chains in our application, we need to code an additionnal class (i.e ServerDelegatingSoapHandler2 calling serverHandlers2).

    So, this solution is far from ideal.

    Do you think about a better solution ?
    Has anyone before configured serveur side JAX-WS handlers with spring ?

    Thanks !

  3. #3
    Join Date
    Oct 2007
    Posts
    5

    Default Same problem here

    I'm implementing a Web Services backend using JAX-WS and tackled the exact same problem.
    The only remote topic is Spring Web Services, which has interceptors, but it seems that this project ignores JAX-WS completely and/or WSDL2Java code generation.

  4. #4
    Join Date
    Jul 2005
    Posts
    156

    Default

    I didn't found a better solution than implementing my own ServerDelegatingSoapHandler which delegates to a Spring jax-ws handler chain (as shown in the second post).

  5. #5
    Join Date
    Oct 2007
    Posts
    5

    Default Solved

    Apparently Spring does support defining SOAP Handlers. It's not exactly Spring it self, but an extension of Spring written JAX-WS.

    First you should wire your Web Service Bean Implementation to Spring through this link.
    Once you have your Web Service as a Spring bean, and it is defined using JAX-WS Spring extension, you can use its nested elements to define, among other things, handler chains using this link.

    Funny thing is that @HandlerChain didn't work for me at all. I think it's due to the fact that I was using JAX-WS Spring extension to load the Web Service implementation.

    Tell me if it helped you.

    Asaf

  6. #6
    Join Date
    Jul 2005
    Posts
    156

    Default

    Thanks, I'll check the link.

    I've looked at it some time ago, and I had the impression that jax-ws-commons.dev.java.net were tied to metro web service stack and would not work with another stack (I'm using IBM Web Service Feature Pack based on Axis 2).

    I'll check a bit more and let you know, thanks once more !

  7. #7
    Join Date
    Jul 2005
    Posts
    156

    Default

    Funny thing is that @HandlerChain didn't work for me at all. I think it's due to the fact that I was using JAX-WS Spring extension to load the Web Service implementation.
    Exactly, from the docs, you configure jax-ws handlers in the spring configuration file as indicated here https://jax-ws-commons.dev.java.net/spring/handler.html. No need of @HandlerChain annotation anymore.

    I've looked at it some time ago, and I had the impression that jax-ws-commons.dev.java.net were tied to metro web service stack
    Yes, I confirm, https://jax-ws-commons.dev.java.net/spring/ is completely tied to JAX WS RI implementation, you cannot use it with another web service stack.
    So, this is a show stopper for me ;(.

    If you use JAX-WS RI stack though, this extension can really help you.
    Also, cxf (http://cxf.apache.org/) integrates really well with Spring.

    All in all, there's no extension allowing a spring user to define jax-ws handlers in a portable way between different web service stacks - and from my point of view it's a bit surprising.

    I can give you our source code if it helps you (I needed it since Websphere Web Service Feature Pack didn't provide any spring native integration). But, if you use jax-ws ri implementation you're better staying with the jax-ws-commons extension though.

    Adrian

  8. #8
    Join Date
    Feb 2009
    Posts
    15

    Exclamation How to refer ibm's JAX-WS runtime to Spring!?

    Dear all,

    I am trying to use handler in spring for JAX-WS and I am getting the below error.Spring is looking for jaxws-api.jar to run. As i have already enabled jax-ws feature in my environment, spring is not taking ibm's jax-ws runtime. Could any one assist me to refer the spring to ibm's jax-ws runtime ?

    FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: javax.xml.ws.WebServiceFeature

    thanks
    brajesh

  9. #9
    Join Date
    Oct 2007
    Posts
    5

    Default Spring With IBM

    It's doesn't like a problem related to Spring, but more to classpath issues and missing jar files, right?
    What's your environment looks like exactly?

  10. #10
    Join Date
    Jul 2005
    Posts
    156

    Default

    Code:
    FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: javax.xml.ws.WebServiceFeature
    WebServiceFeature is a new class of JAX-WS 2.1.
    WAS 6.1 Web Service Feature Pack supports only JAX-WS2.0.

    I'm using Spring and WAS 6.1 WSFP, and never had this error (and I made sure using Eclipse and CTRL+SHIFT+T that WebServiceFeature couldn't be found on the classpath).

    Can you post your Spring configuration file ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •