A wsdl is created by a java class ( Dao ). After adding reflection, session cannot be get. Code snippets are as follows.
Error message is : unwinding now: java.lang.reflect.InvocationTargetException: null
If the method does not contain this.getSession, it works fine. However, it seems that in the new instance, session is null if a method has this.getSession.
How to get current instance to get session?
Thanks
@WebService(name="webService",serviceName="webServiceSrc",targetNamespace="http://com.ws.org")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
use=SOAPBinding.Use.LITERAL,
parameterStyle=SOAPBinding.ParameterStyle.WRAPPED
)
public class WebService extends HibernateDaoSupport{
...........
private String GetCityData(String userid, Long city, Integer version){
String hql="from CityInfo t where t.filename='"+Long.toString(city)+"'";
Session session = this.getSession();
...................................
}
public String CommonWS(String paramString) throws Exception{
..........................
String functionName="";
ArrayList<Object []>s = parseXml2(paramString);
functionName = s.get(0)[0].toString();
Class<?>[] mapValue = WStype.map.get(functionName);
Class cl=Class.forName("com.ws.WebService");
Method m=cl.getDeclaredMethod(functionName, mapValue);
m.setAccessible(true);
Object[] newobject=getObject(s.get(1), mapValue);
m.invoke(cl.newInstance(), newobject);
return null;
}
}
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<!-- SpringContextUtils定义 -->
<bean id="springContextUtils" class="com.framework.core.utils.SpringContextUtils" lazy-init="false"/>
<!-- WebService -->
<bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<bean id="webServiceBean" class="com.ws.WebService" >
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- WSDL -->
<jaxws:endpoint id="webService" implementor="#webServiceBean" address="/webService" />