2 Replies Latest reply on Jul 7, 2011 7:17 AM by asoldano

    Jboss+jbossws-cxf-3.4.1.GA and spring 3.0.5 : how to publish a cxf web service instantiated in spring

    aminem

      Hi,

       

       

      As part of a project, i should use Jboss+jbossws-cxf-3.4.1.GA and spring 3.0.5. Problem : I'am newbie on JBoss

       

       

      After some researchs, and according of Jboss-CXF and apache-Cxf documentation it seem that some important difference exist to configure cxf+spring when it is integrated to Jboss 6.0 final.

       

       

      In order to understand how is it running, i developed a web service in a maven project :

       

       

      package example;
      
      
      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebParam.Mode;
      import javax.jws.WebResult;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.jws.soap.SOAPBinding.Style;
      import javax.jws.soap.SOAPBinding.Use;
      
      
      
      
      @WebService(name = "AuthenticateWS", portName = "AuthenticatePort", serviceName = "AuthenticateService")
      @SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL)
      public class AuthenticateWS {
      
                public AuthenticateWS(){
                }
      
      
                @WebMethod(operationName = "authenticate")
                @WebResult(partName = "authenticateResponse", name = "id_user", targetNamespace = "client.clirisgroup.com")
                public int authenticate(
                                    @WebParam(mode = Mode.IN, name = "login", partName = "authenticateRequest") String login,
                                    @WebParam(mode = Mode.IN, name = "password", partName = "authenticateRequest") String password) {
                          return -1;
                }
      
                @WebMethod(operationName="resetAccount")
                @WebResult(name="resetSucceed", partName="resetAccountResponse", targetNamespace="client.clirisgroup.com")
                public int resetAccount(@WebParam(mode = Mode.IN, name = "email", partName = "resetAccountRequest")String email){
                          return -1;
                }
      
      
      }
      

       

      my WBE-INF/beans.xml file contains the following code :

       

       

      <beans xmlns='http://www.springframework.org/schema/beans'
                xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
                xmlns:beans='http://www.springframework.org/schema/beans'
                xmlns:jaxws='http://cxf.apache.org/jaxws'
                xsi:schemaLocation='http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://cxf.apache.org/jaxws
        http://cxf.apache.org/schemas/jaxws.xsd'>
      
      
                <jaxws:endpoint id="AuthenticateEndPoint"
                          implementor="example.AuthenticateWS" address="http://@jboss.bind.address@:8080/portal-services/AuthenticateEndPoint" publish="true" >
                          <jaxws:invoker>
                  <bean class='org.jboss.wsf.stack.cxf.InvokerJSE' />
              </jaxws:invoker>
                </jaxws:endpoint>
      </beans>
      

       

      and my WEB-INF/web.xml contains nothing :

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
                version="3.0">
                <!-- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" -->
      
      
                <display-name>example</display-name>
      
      </web-app>
      

       

      i don't have error when i deploy my web service on the server (*.war packaging). But i note that my web service (declared in beans.xml) is not published even if i set  publish="true".

       

       

      Also i don't found my web service in my JBoss Web Services Console. I suppose that There's something I don't get.

       

       

      Can you help me, please.

       

       

      Thank you in advance.

       

       

      Some info:

      I use JBoss 6.0 final.

      i compiled installed with the flag -Dspring=true

      I added spring libs to <JBOSS_HOME>/common/lib

        • 1. Re: Jboss+jbossws-cxf-3.4.1.GA and spring 3.0.5 : how to publish a cxf web service instantiated in spring
          aminem

          After many tests, i found a configuration that work.

           

          My WEB-INF/jboss-cxf.xml (and not beans.xml, according to jbossws-cxf documentation, spring file must be named jboss-cxf in order to jboss take it automatically):

           

          <beans xmlns='http://www.springframework.org/schema/beans'
                    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
                    xmlns:beans='http://www.springframework.org/schema/beans'
                    xmlns:jaxws='http://cxf.apache.org/jaxws'
                    xsi:schemaLocation='http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://cxf.apache.org/jaxws
            http://cxf.apache.org/schemas/jaxws.xsd'>
          
                      <beans:bean id="AuthenticateWSBean" class="example.AuthenticateWS" >
                      </beans:bean>
          
          
                    <jaxws:endpoint id="AuthenticateEndPoint" publish="true"
                              implementor="#AuthenticateWSBean" address="http://localhost:8080/portal-services/AuthenticateEndPoint" 
                              implementorClass="example.AuthenticateWS" 
                              serviceName="AuthenticateService" >
                              <jaxws:invoker>
                      <bean class='org.jboss.wsf.stack.cxf.InvokerJSE' />
                  </jaxws:invoker>
                    </jaxws:endpoint>
          </beans>
          

           

          My WEB-INF/web.xml :

          <?xml version="1.0" encoding="UTF-8"?>
          <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
           <!-- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" -->
           <display-name>portalServices</display-name>
          
          <servlet>
            <servlet-name>authServlet</servlet-name>
            <servlet-class>example.AuthenticateWS</servlet-class>
           </servlet>
          <servlet-mapping>
            <servlet-name>authServlet</servlet-name>
             <url-pattern>/*</url-pattern>
           </servlet-mapping> 
          </web-app>
          

           

          Obviously, in order to instantiate all web services declared in jboss-cxf.xml, I only need to declare in my web.xml an instance of one of my web services and associate it the url-pattenr /*

          Why it is needed to do that? I don’t know? Can you shed some light on this?

          Does it exist another solution more elegant to do the same thing?

          • 2. Re: Jboss+jbossws-cxf-3.4.1.GA and spring 3.0.5 : how to publish a cxf web service instantiated in spring
            asoldano

            The servlet and servlet mapping stuff in web.xml is the default way of declaring a POJO ws endpoint on JBoss.

            The spring configuration is an optional addition for those needing to provide some further configuration that can be done through the cxf spring descriptor only. As a matter of fact, you could simply avoid the spring declaration here and let jbossws deploy the endpoint without it.