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/11/24 01:34:13 UTC

restful_http_binding and WebServiceContext

I am trying to figure out how to get access to WebServiceContext in the
restful_http_binding sample that comes with CXF. 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 (CXF-1074).

I am new to CXF, so I may be doing something fundamentally wrong here.

Any ideas?

Thanks,
-mike

Re: restful_http_binding and WebServiceContext

Posted by Daniel Kulp <dk...@apache.org>.
Mike,

Are you using CXF 2.0.3?
Also, is the impl created via a jaxws:endpoint spring config thing?   If 
so, can I see the spring config?

Onw workaround is to do:

context = new org.apache.cxf.jaxws.context.WebServiceContextImpl();

Kind of sucks though and would definitely not be portable.    It SHOULD 
have been injected in.


Dan


On Friday 23 November 2007, 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. 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 (CXF-1074).
>
> I am new to CXF, so I may be doing something fundamentally wrong here.
>
> Any ideas?
>
> Thanks,
> -mike



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: restful_http_binding and WebServiceContext

Posted by Davide Gesino <wi...@libero.it>.
or maybe in a RESTful WS the context is not injected at all, due to the
nature of REST.

Davide Gesino wrote:
> 
> Hi,
> 
> It's quite strange, the context should be injected... I think the only way
> to obtain the WebServiceContext is through DI, I have not found a way to
> obtai ntha same programmatically.
> Did you provide getters and setters for the WebServiceContext? May depend
> on that.
> 
> Davide
> 
> 
> 
> Michael Nelson-5 wrote:
>> 
>> I am trying to figure out how to get access to WebServiceContext in the
>> restful_http_binding sample that comes with CXF. 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 (CXF-1074).
>> 
>> I am new to CXF, so I may be doing something fundamentally wrong here.
>> 
>> Any ideas?
>> 
>> Thanks,
>> -mike
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/restful_http_binding-and-WebServiceContext-tf4875856.html#a13969474
Sent from the cxf-user mailing list archive at Nabble.com.


Re: restful_http_binding and WebServiceContext

Posted by Davide Gesino <wi...@libero.it>.
@Resource(type=Object.class)

annotating in this way changes something?



Davide Gesino wrote:
> 
> Hi,
> 
> It's quite strange, the context should be injected... I think the only way
> to obtain the WebServiceContext is through DI, I have not found a way to
> obtai ntha same programmatically.
> Did you provide getters and setters for the WebServiceContext? May depend
> on that.
> 
> Davide
> 
> 
> 
> Michael Nelson-5 wrote:
>> 
>> I am trying to figure out how to get access to WebServiceContext in the
>> restful_http_binding sample that comes with CXF. 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 (CXF-1074).
>> 
>> I am new to CXF, so I may be doing something fundamentally wrong here.
>> 
>> Any ideas?
>> 
>> Thanks,
>> -mike
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/restful_http_binding-and-WebServiceContext-tf4875856.html#a13969474
Sent from the cxf-user mailing list archive at Nabble.com.


Re: restful_http_binding and WebServiceContext

Posted by Willem Jiang <ni...@iona.com>.
FYI , DI happens in JaxWsServerFactoryBean's[1] init() method.

[1]https://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java

Willem.

Davide Gesino wrote:
> Hi,
>
> It's quite strange, the context should be injected... I think the only way
> to obtain the WebServiceContext is through DI, I have not found a way to
> obtai ntha same programmatically.
> Did you provide getters and setters for the WebServiceContext? May depend on
> that.
>
> Davide
>
>
>
> Michael Nelson-5 wrote:
>   
>> I am trying to figure out how to get access to WebServiceContext in the
>> restful_http_binding sample that comes with CXF. 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 (CXF-1074).
>>
>> I am new to CXF, so I may be doing something fundamentally wrong here.
>>
>> Any ideas?
>>
>> Thanks,
>> -mike
>>
>>
>>     
>
>   

Re: restful_http_binding and WebServiceContext

Posted by Davide Gesino <wi...@libero.it>.
@Resource(type=Object.class)

annotating in this way changes something?


-- 
View this message in context: http://www.nabble.com/restful_http_binding-and-WebServiceContext-tf4875856.html#a13969474
Sent from the cxf-user mailing list archive at Nabble.com.


Re: restful_http_binding and WebServiceContext

Posted by Davide Gesino <wi...@libero.it>.
Hi,

It's quite strange, the context should be injected... I think the only way
to obtain the WebServiceContext is through DI, I have not found a way to
obtai ntha same programmatically.
Did you provide getters and setters for the WebServiceContext? May depend on
that.

Davide



Michael Nelson-5 wrote:
> 
> I am trying to figure out how to get access to WebServiceContext in the
> restful_http_binding sample that comes with CXF. 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 (CXF-1074).
> 
> I am new to CXF, so I may be doing something fundamentally wrong here.
> 
> Any ideas?
> 
> Thanks,
> -mike
> 
> 

-- 
View this message in context: http://www.nabble.com/restful_http_binding-and-WebServiceContext-tf4875856.html#a13969469
Sent from the cxf-user mailing list archive at Nabble.com.