Thursday 15 May 2014

cxf - Getting access to a spring bean from a webservice? -


I have created a CXF webservice within my cxf.xml file. I have the following tag. Bean id = "VideoStatable" category = "com.company.auth.dataobjects.VideoStatsTable"

I think Spring should make this object for me The problem is that I'm not sure how to get it. It seems like I need servlet contact but as I am not in servlet im in WS, I'm not sure how to do this?

W

<

In your applicationContext.xml

xmlns: jaxws = "http: // cxf

.apache.org / jaxws " add http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org Add / jaxws http://cxf.apache.org/ schema / jaxws.xsd

to your schema location

  & lt ;! - - Loading CXF module - & gt; & Lt; Import Resources = "Classpath: Meta-INF / cxf / cxf.xml" /> & Lt; Import Resources = "Classpath: Meta-INF / cxf / cxf-extension-soap.xml" /> & Lt; Import Resources = "Classpath: Meta-INF / CXF / CXF-Servlet.XML" />  

And finally declare your WebService implementation:

  & lt; Jaxws: endpoint id = "MyWebService" implementor = "# MyWebServiceImpl" address = "/ myWebServiceAddress" />  

Where #MyWebServiceImpl is the ID of your bean, you can inject any other spring dependency independently into that bean.

Then the web service can be accessed via http: // yourhost / cxfuri / myWebServiceAddress (where cxfuri mapping is your CXF service)


No comments:

Post a Comment