[jboss-user] [JBossWS] - Re: Writing a client - no examples for BindingProvider based

alessio.soldano@jboss.com do-not-reply at jboss.com
Mon Jan 7 05:02:58 EST 2008


The EntityManager injection should work given you're using an EJB3 endpoint. I personally used it:

WS endpoint & EJB SLSB impl:

  | @Stateless
  | @WebService(name="TestCaricoWS",
  | 		   targetNamespace = "http://www.xxx.it/TestCarico",
  | 		   serviceName = "TestCaricoWSService")
  | @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
  | public class TestCaricoSessionBean implements TestCaricoInterface {
  | 	
  | 	@Resource
  | 	private SessionContext ctx;
  | 	
  | 	@PersistenceContext(unitName = "TestCarico")
  | 	private EntityManager manager;
  |         
  |         @TransactionAttribute(TransactionAttributeType.REQUIRED)
  | 	@WebMethod(operationName="performTest")
  | 	@Oneway
  | 	public void performTest(@WebParam(name="uffa") Uffa uffa) {
  |                 Query query = manager.createQuery("from TestCarico where cdTestCarico>=:from and cdTestCarico<=:to");
  | 		query.setParameter("from", uffa.getFrom());
  | 		query.setParameter("to", uffa.getTo());
  | 		List<TestCarico> entities = query.getResultList();
  | ....
  | 

Interface:

  | @Local
  | public interface TestCaricoInterface {
  | 	
  | 	public void performTest(Uffa uffa) throws Exception;
  | ....
  | 

Datasource:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <datasources>
  |    
  |   	<xa-datasource>
  |    		<jndi-name>TestCaricoDatasource</jndi-name>
  | 	    <track-connection-by-tx/>
  | 	    <isSameRM-override-value>false</isSameRM-override-value>
  | 	    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
  | 	    <xa-datasource-property name="URL">jdbc:oracle:thin:@10.10.10.1:1523:MYSID</xa-datasource-property>
  | 	    <xa-datasource-property name="User">user</xa-datasource-property>
  | 	    <xa-datasource-property name="Password">pwd</xa-datasource-property>
  | 	    <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
  | 	    <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
  | 	    <!-- Checks the Oracle error codes and messages for fatal errors -->
  | 	    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
  | 	    <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
  | 	    <no-tx-separate-pools/>
  |         <min-pool-size>1</min-pool-size>
  |         <max-pool-size>100</max-pool-size>
  |         <blocking-timeout-millis>5000</blocking-timeout-millis>
  |         <idle-timeout-minutes>1</idle-timeout-minutes>
  | 	</xa-datasource>
  | 
  | </datasources>
  | 

persistence.xml:

  | <?xml version="1.0" encoding="UTF-8"?>
  | <persistence xmlns="http://java.sun.com/xml/ns/persistence"
  | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
  | 	version="1.0">
  | 
  | 	<persistence-unit name="TestCarico">
  | 		<provider>org.hibernate.ejb.HibernatePersistence</provider>
  | 		<jta-data-source>java:/TestCaricoDatasource</jta-data-source>
  | 		<properties>
  | 			<property name="hibernate.dialect"
  | 				value="org.hibernate.dialect.HSQLDialect" />
  | 			<property name="hibernate.show_sql" value="true" />
  | 			<property name="jboss.entity.manager.factory.jndi.name"
  | 				value="java:/TestCaricoEntityManagerFactory" />
  | 		</properties>
  | 	</persistence-unit>
  | </persistence>
  | 

Please note that no manual actions with transactions and so on is required.
Hope this helps, anyway for qualified support about EJB3 questions also refer to http://www.jboss.com/index.html?module=bb&op=viewforum&f=221. 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4117466#4117466

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4117466



More information about the jboss-user mailing list