You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Michael Nelson <mi...@gmail.com> on 2007/12/02 06:33:49 UTC

Re: restful_http_binding and WebServiceContext

Cool. That did the trick. Thanks!

-mike

On Nov 25, 2007 5:55 PM, Willem Jiang <ni...@iona.com> wrote:

> Hi Mike,
>
> I just checked the code , you need to specify the Service Bean object to
> be injected with the WebServiceContext.
>
> Here is an example for you:
>  private static void createRestService(Object serviceObj) {
>        // Build up the server factory bean
>        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
>        sf.setServiceClass(CustomerService.class);
>        // Use the HTTP Binding which understands the Java Rest Annotations
>        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
>        sf.setAddress("http://localhost:8080/xml/");
>        // *** just set the service object as the service bean directly
> , to get the webservice context object to been injected.
>        sf.setServiceBean(serviceObj);
>
>        // Turn the "wrapped" style off. This means that CXF won't generate
>        // wrapper XML elements and we'll have prettier XML text. This
>        // means that we need to stick to one request and one response
>        // parameter though.
>        sf.getServiceFactory().setWrapped(false);
>
>        sf.create();
>    }
>
> Willem.
>
> Michael Nelson wrote:
> > I am trying to figure out how to get access to WebServiceContext in the
> > restful_http_binding sample that comes with CXF 2.0.3. In
> > CustomerServiceImpl.java, I've added:
> >
> >     @Resource
> >     private WebServiceContext wsContext;
> >
> > to the CustomerServiceImpl class.
> >
> > But wsContext isn't set when methods are invoked. I've looked through
> the
> > archives and the only issue I've seen seems to be if you use Spring and
> > transactions.
> >
> > I am new to CXF, so I may be doing something fundamentally wrong here.
> >
> > Any ideas?
> >
> > Thanks,
> > -mike
> >
> >
>