java - How to access DAO from Webservice using JAX-WS -
just started using jax-ws. created service class , dao class. service running fine gives nullpointerexeption b'coz can't locate dao; trying call dao service class :
package com.nmmc.works.service.impl; @webservice(servicename="myservice") public class securityserviceimpl extends genericserviceimpl implements isecurityservice { private isecuritydao securitydao; ....getter setter methods.... @webmethod public integer getbidacceptanceidforsdpayment(integer tmastno) { internalresultsresponse<object> response = getsecuritydao().getmymethod(tendermastno); if(response != null && response.getresultslist().size() > 0){ return integer.parseint(response.getfirstresult().tostring()); }else{ return -1; } }
and sun-jaxws.xml.....
<b> <?xml version="1.0" encoding="utf-8"?> <endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"> <endpoint implementation="com.nmmc.works.service.impl.securitydepositserviceimpl" name="myservices" url-pattern="mypath/securityserviceimpl" /> </endpoints></b>
in web.xml....
<b><listener> <listener-class>com.sun.xml.ws.transport.http.servlet.wsservletcontextlistener</listener-class> </listener> <servlet> <servlet-name>webservices</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.wsservlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>webservices</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping></b>
your securityserviceimpl doesn't have dao in when run it. you'll have ensure dao created , injected into/obtained it.
Comments
Post a Comment