LibraryToggle FramesPrintFeedback

Complete the following steps to expose your J2EE application, implemented as a SLSB, as a Web service using the Apache CXF JCA Connector:

  1. Write a SLSB that implements the service that you want to expose. See, for instance, GreeterBean.java located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/src/demo/ejb and shown in Example 2.5.


  2. Write an EJB Local Home interface for your SLSB. See, for instance, GreeterLocalHome.java located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/src/demo/ejb and shown in Example 2.6.


  3. Write a deployment descriptor for your SLSB and ensure that it includes:

    See, for instance, the ejb-jar.xml located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/etc and shown in Example 2.7.

    Example 2.7. Stateless Session Bean Deployment Descriptor—ejb-jar.xml

    <?xml version="1.0"?>
                                ...
    <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
           http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
           version="2.1">
                                    
       <enterprise-beans>
          <session>
             <ejb-name>DispatchedGreeterBean</ejb-name>
             <home>demo.ejb.GreeterHome</home>
             <remote>demo.ejb.GreeterRemote</remote>
             <local-home>demo.ejb.GreeterLocalHome</local-home>
             <local>demo.ejb.GreeterLocal</local>
             <ejb-class>demo.ejb.GreeterBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
           </session>
                                        
           <message-driven>
             <ejb-name>GreeterEndpointActivator</ejb-name>
             <ejb-class>org.apache.cxf.jca.inbound.DispatchMDBMessageListenerImpl</ejb-class>
             <messaging-type>org.apache.cxf.jca.inbound.DispatchMDBMessageListener
             </messaging-type>
             <transaction-type>Bean</transaction-type>
                                            
             <activation-config>
                  <!-- display name-->
                  <activation-config-property>
                      <activation-config-property-name>
                         DisplayName
                      </activation-config-property-name>
                      <activation-config-property-value>
                         DispatchedGreeterEndpoint
                      </activation-config-property-value>
                  </activation-config-property>
                  <!-- service endpoint interface -->
                  <activation-config-property>
                      <activation-config-property-name>
                         serviceInterfaceClass
                      </activation-config-property-name>
                      <activation-config-property-value>
                         org.apache.hello_world_soap_http.Greeter
                      </activation-config-property-value>
                  </activation-config-property>
                  <!-- address -->
                  <activation-config-property>
                      <activation-config-property-name>
                         address
                      </activation-config-property-name>
                      <activation-config-property-value>
                         http://localhost:9999/GreeterBean
                      </activation-config-property-value>
                  </activation-config-property>
                  <!-- targetBeanJndiName -->
                  <activation-config-property>
                      <activation-config-property-name>
                          targetBeanJndiName
                     </activation-config-property-name>
                     <activation-config-property-value>
                         java:comp/env/DispatchedGreeterLocalHome
                     </activation-config-property-value>
                  </activation-config-property>
              </activation-config>
                                       
              <ejb-local-ref>
                  <ejb-ref-name>DispatchedGreeterLocalHome</ejb-ref-name>
                  <ejb-ref-type>Session</ejb-ref-type>
                  <local-home>demo.ejb.GreeterLocalHome</local-home>
                  <local>demo.ejb.GreeterLocal</local>
                  <ejb-link>DispatchedGreeterBean</ejb-link>
              </ejb-local-ref>
           </message-driven>
                                        
         </enterprise-beans>
    </ejb-jar>

    For more information about the supported activation configuration properties, see Inbound Activation Configuration.

    If you are using EJB 3.0, the only change you need to make to the deployment descriptor is in the opening ejb-jar element. For EJB 3.0 it should read as shown in Example 2.3.

  4. Package your application in an EJB JAR file.

  5. Build the Apache CXF JCA Connector RAR file. It must have the following structure and contents:

    1. META-INF directory — Must contain the ra.xml, located in InstallDir/samples/integration/jca/inbound-mdb-dispatch/etc.

    2. Root directory — Must contain the JAR files listed under Root in Table 2.1.

    The sample application's build.xml file includes a generate.rar target that you can use to build the RAR file (see Example 2.4).

    Note that the ra.xml file activation spec is set to org.apache.cxf.jca.inbound.DispatchMDBActivationSpec, which includes a targetBeanJndiName configuration property that enables you to specify your SLSB's JNDI name.

  6. Deploy the Apache CXF JCA Connector RAR file and your EJB JAR file to your J2EE application server. For details, see Deploying Apache CXF JCA Connector.

Comments powered by Disqus