| Apache CXF Documentation > Index > Deployment > Use CXF-JCA RAR |
cxf-integration-jca module has implemented the JCA1.5 outbound connection. You can see samples in $CXF_HOME/samples/integration/jca.
The jca rar package structure would be:
|---META-INF
|---META-INF/ra.xml
|---cxf-api-2.1.jar
|---cxf-integration-jca-2.1.jar
|---.....
Refer to this build.xml
"generate.rar" target for building rar detail.
(Note: This has been tested against JBoss4.0.5)
<!DOCTYPE connection-factories
PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
"http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<connection-factories>
<no-tx-connection-factory>
<jndi-name>CXFConnector</jndi-name>
<rar-name>cxf.rar</rar-name>
<connection-definition>org.apache.cxf.connector.CXFConnectionFactory</connection-definition>
</no-tx-connection-factory>
</connection-factories>
You can refer to jca sample's README
for detail.
(Note: This has been tested against JBoss4.0.5 and JBoss4.2.1)
<?xml version="1.0" encoding="UTF-8"?> <application> <display-name>cxf-jca</display-name> <module> <connector>cxf.rar</connector> </module> </application>
<?xml version="1.0" encoding="UTF-8"?> <jboss-app> <loader-repository> apache.cxf:loader=cxf.ear <loader-repository-config> java2ParentDelegation=true </loader-repository-config> </loader-repository> <module> <service>cxf-ds.xml</service> </module> </jboss-app>
<?xml version="1.0" encoding="UTF-8"?> <connection-factories> <no-tx-connection-factory> <jndi-name>CXFConnector</jndi-name> <rar-name>cxf.ear#cxf.rar</rar-name> <connection-definition>org.apache.cxf.connector.CXFConnectionFactory</connection-definition> </no-tx-connection-factory> </connection-factories>
|
The rar name should be full name, which is ear-name#rar-name, instead of rar-name alone. |
(Note: this has been tested against WebLogic9.1)
<weblogic-connector xmlns="http://www.bea.com/ns/weblogic/90"> <outbound-resource-adapter> <connection-definition-group> <connection-factory-interface>org.apache.cxf.connector.CXFConnectionFactory</connection-factory-interface> <connection-instance> <jndi-name>CXFConnector</jndi-name> </connection-instance> </connection-definition-group> </outbound-resource-adapter> </weblogic-connector>
TBD
Below is the code snippet to get the Connection.
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); CXFConnectionRequestInfo cri = new CXFConnectionRequestInfo(Greeter.class, wsdl, serviceName, portName); ManagedConnectionFactory managedFactory = new ManagedConnectionFactoryImpl(); Subject subject = new Subject(); ManagedConnection mc = managedFactory.createManagedConnection(subject, cri); Object o = mc.getConnection(subject, cri);
Also can get the connection without wsdl, but you need to provide the address.
CXFConnectionRequestInfo requestInfo = new CXFConnectionRequestInfo(); requestInfo.setInterface(Greeter.class); requestInfo.setAddress("http://localhost:9000/SoapContext/SoapPort"); ManagedConnectionFactory factory = new ManagedConnectionFactoryImpl(); ManagedConnection mc = factory.createManagedConnection(null, requestInfo); Object client = mc.getConnection(null, requestInfo);
By using cxf-jca RAR, the EIS is able to access the Stateless Session Bean by CXF Interal API or JAXWS API.
If you want to deploy the Stateless Session Bean, you need to modify the ejb_servant.properties file.
# Format:
# jndi_name={namespace}ServiceName@url_to_swdl
#
# jndi_name: The JNDI name that an external client uses to contact the bean.
# ServiceName: The string form of the QName for the Artix service in the WSDL file.
# @url_to_wsdl: The string form of a URL that identifies the WSDL file.
#
# Example:
# GreeterBean={http://apache.org/hello_world_soap_http}Greeter@file:c:/wsdl/hello_world.wsdl
|
You can specify the ejb_servant.properties file location in the $RAR/META-INF/ra.xml "EJBServicePropertiesURL" property value. |
|
You need to deploy the ejbs before activate the ejb_servant.properties file, otherwise, it won't find the JNDI name. |