Back Forum Reply New

Web Service (AXIS) and Transactions

I have created a method (performs reads and writes) that I can get to work correctly using the from Invoker. I have defined the Transaction correctly and I am using OpenSessionInViewFilter.  
Now I want to make this method available via JAX-RPC and AXIS. I have successfully created a service that does a query, but if I want to perform an update, I get the following Error:
Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition

It seems that the web service is not picking up the session?

Here is some of my ApplicationContext.xml:

Code:
lt;bean id=quot;IAdHocWebStatelessquot; class=quot;com.weenergies.fo.p2ei.portal.control.WebStateControllerquot;gt;lt;/beangt;lt;!--  Transactions objects defined here --gt;
lt;!--  This bean defines a quotarentquot; transaction bean.   It defines the default properties for transactions . --gt;
lt;bean id=quot;txProxyTemplatequot; abstract=quot;truequot; class=quot;org..transaction.interceptor.TransactionProxyFactoryBeanquot;gt;
lt;property name=quot;transactionManagerquot;gt;
lt;ref bean=quot;transactionManagerquot; /gt;
lt;/propertygt;
lt;property name=quot;transactionAttributesquot;gt;
lt;propsgt;
lt;prop key=quot;*quot;gtROPAGATION_REQUIREDlt;/propgt;
lt;/propsgt;
lt;/propertygt;
lt;/beangt;

lt;!--  This bean is used when there is a query to get data. It is wrapped in transactions --gt;
lt;bean id=quot;adHocQueryGetDataServicequot; parent=quot;txProxyTemplatequot;gt;
lt;property name=quot;targetquot;gt;
lt;ref local=quot;IAdHocWebStatelessquot; /gt;
lt;/propertygt;
lt;/beangt;
Here is some of my web.xml:

Code:
lt;filtergt;
lt;filter-namegt;AdHocQueryHibernateFilterlt;/filter-namegt;
lt;filter-classgt;org..orm.hibernate3.support.OpenSessionInViewFilterlt;/filter-classgt;
lt;/filtergt;

lt;filter-mappinggt;
lt;filter-namegt;AdHocQueryHibernateFilterlt;/filter-namegt;
lt;ucl-patterngt;/*lt;/ucl-patterngt;
lt;/filter-mappinggt;

lt;servletgt;
lt;descriptiongt;This is used for the any requsts for data through the Web Service.lt;/descriptiongt;
lt;display-namegt;AdHocQueryWebServicelt;/display-namegt;
lt;servlet-namegt;AdHocQueryWebServicelt;/servlet-namegt;
lt;servlet-classgt;org.apache.axis.transport.from.AxisServletlt;/servlet-classgt;
lt;/servletgt;

lt;servlet-mappinggt;
lt;servlet-namegt;AdHocQueryWebServicelt;/servlet-namegt;
lt;ucl-patterngt;/services/*lt;/ucl-patterngt;
lt;/servlet-mappinggt;
and here is all of my server-config.wsdd

Code:
lt;deployment xmlns=quot;axis/wsdd/quot;
xmlns:java=quot;axis/wsdd/providers/javaquot;gt;

lt;handler name=quot;uclMapperquot;
type=quot;javarg.apache.axis.handlers.from.uclMapperquot; /gt;

lt;service name=quot;AdHocQueryWebServicequot; provider=quot;java:RPCquot;gt;
lt;parameter name=quot;classNamequot;
value=quot;com.weenergies.fo.p2ei.portal.webService.AdHocQueryServiceImplquot; /gt;
lt;parameter name=quot;allowedMethodsquot; value=quot;*quot; /gt;
lt;/servicegt;

lt;transport name=quot;fromquot;gt;
lt;requestFlowgt;
lt;handler type=quot;uclMapperquot; /gt;
lt;/requestFlowgt;
lt;/transportgt;
lt;/deploymentgt;
In my class 'AdHocQueryServiceImpl.onInit() method I have the following:

Code:
webCall = (WebStateController) getWebApplicationContext().getBean(quot;IAdHocWebStatelessquot;);
Then I call my method that has write operations on the database.

I must be missing something but I can't figure it out.

Thanks for your time,
Dennis

You should use your own session/transaction for write operations, not the session provided by OSIV, which is read-only.

I didn't realize that OSIV is read-only. So I need to extend OSIV and implement what I need. Do you know of any good examples off hand?

I don't think you need OSIV at all. Try to take it out and do it the good old way - inject HibernateTemplate into IAdHocWebStateless and use it for all the calls. The transaction you defined around IAdHocWebStateless methods will take care of keeping the session open.
¥
Back Forum Reply New