LibraryToggle FramesPrintFeedback

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

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


  2. Write a deployment descriptor for your MDB. See, for instance, the ejb-jar.xml file located in InstallDir/samples/integration/jca/inbound-mdb/etc and shown in Example 2.2.

    Example 2.2. Message Driven 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>
          <message-driven>
             <ejb-name>Greeter MDB</ejb-name>
             <ejb-class>demo.ejb.GreeterBean</ejb-class>
             <messaging-type>
                org.apache.hello_world_soap_http.Greeter
             </messaging-type>
             <transaction-type>Bean</transaction-type>
     
             <activation-config>          
                <!-- displayName -->
                <activation-config-property>
                   <activation-config-property-name>
                      displayName
                   </activation-config-property-name>
                   <activation-config-property-value>
                      MyCxfEndpoint
                   </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>
                                                
                </activation-config>
             </message-driven>
          </enterprise-beans>
                                    
               <assembly-descriptor>
               <method-permission>
                  <unchecked/>
                  <method>
                     <ejb-name>GreeterBean</ejb-name>
                     <method-name>*</method-name>
                  </method>
               </method-permission>
                   <container-transaction>
                       <description/>
                       <method>
                          <description/>
                          <ejb-name>GreeterBean</ejb-name>
                          <method-name>*</method-name>
                       </method>
                       <trans-attribute>Supports</trans-attribute>
                    </container-transaction>
                </assembly-descriptor>
    </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.


  3. Package you application in an EJB JAR file.

  4. Make a copy of the Apache CXF JCA Connector's deployment descriptor file, ra.xml, which is located in the samples/integration/jca/websphere/inbound-mdb/etc directory of your installation.

  5. Edit the ra.xml file so that the messagelistener-type element defines the same interface as the messaging-type element defined in your MDB deployment descriptor. This ensures that the Apache CXF JCA Connector is notified when the MDB starts.

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


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


    The cxf.home variable must be set to the InstallDir directory. This is done for you when you set your environment (see Setting Up Your Environment in Configuring and Deploying Web Service Endpoints.

  7. 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