tags:

views:

60

answers:

1

I have created a cxf webservice within my cxf.xml file I have the following tag. bean id="videoStatsTable" class="com.company.auth.dataobjects.VideoStatsTable"

From what I understand Spring should create this object for me. The problem is I'm not sure how to get access to it. It seems as if I need the servletContext but as I'm in not in a servlet im in a WS im not sure how to do this?

W

+2  A: 

Spring has a simplifed way of declaring web services (wiht cxf).

in your applicationContext.xml add xmlns:jaxws="http://cxf.apache.org/jaxws" to your root tag (<beans>) and

http://cxf.apache.org/core
        http://cxf.apache.org/schemas/core.xsd
        http://cxf.apache.org/jaxws
        http://cxf.apache.org/schemas/jaxws.xsd

to your schemaLocation

Then add:

<!-- Loading CXF modules -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

And finally declare your WebService implementation:

<jaxws:endpoint id="MyWebService" implementor="#MyWebServiceImpl"
    address="/myWebServiceAddress" />

where #MyWebServiceImpl is the ID of your bean. You can freely inject any other spring dependencies into that bean.

Then the web service will be accessible through http://yourhost/cxfuri/myWebServiceAddress (where cxfuri is the mapping of your CXF Servlet)

Bozho