Thanks for your response Sergey. So I have to wait for 2.1.3... a long time? O:-)

What kind of context info is needed ? Perhaps injecting UriInfo or HttpServletRequest, or SecurityContext can do ?
My services are little more complex than helloWorld or 2+2. ;-)
I need the servlet context to get/update two servlet context's attributes containing :
- a caching mechanism that allows time response optimization
- a global engine shared by my different services.
So I don't see another way (without servlet context) to do that, do I?

I'd also like to clarify what exactly happening when you have a single interface ? Is (SOAP) WebServiceContext actually availbale at runtime, when SOAP invocations are made (despite that INFO message) ? Is it what the single problem is when you combine both styles ?
Here are the two points/problems I have noticed :
-1- RESTful annotations (like @Path, @GET, etc) must be on the implementation class (and not on an interface).
While annotating an interface is ok for SOAP service.

-2- The second point is that when I declare my service to be accessible both with SOAP and REST, the WebServiceContext injection never happens. And I have no access to the web service context at runtime. "my service to be accessible both with SOAP and REST" = I have an interface with SOAP annotations and I have an implementation class (my endpoint) containing REST annotations (because it doesn't work if I put these annotations on the interface). In the implementation class, I have an attribute or a setter defined like this :

@Resource
private WebServiceContext context;
or

@Resource
public void setWebServiceContext(WebServiceContext context) { ... }
And my service is deployed using a Spring beans.xml config file containing something like this :

   <jaxws:endpoint
     id="mysoapservice"
     implementor="my.package.MyServiceImpl"
     address="/SoapService" />
<jaxrs:server id="myRestfulService" address="/rest/">
       <jaxrs:serviceBeans>
         <ref bean="MyRestService" />
       </jaxrs:serviceBeans>
   </jaxrs:server>
   <bean id="MyRestService" class="my.package.MyServiceImpl" />
In that case, the context is never injected i.e. the setter is never called. and my web service context is always null. But if I remove the annotation and the REST service declaration in my beans.xml : the injection process is ok and I have access to a web service context at runtime.


-3- To sum up, here is what I want to do (and what i can't for now) :
Have an interface containing both SOAP and REST annotations.
Have a single implementation class (my soap endpoint and rest service bean as well) using a single servlet context injection process to be able to get/update servlet context's attributes.

Example :

@WebService
@Path("/myservice/")
public interface MyService {
@WebMethod
  @GET
  @Path("/{key}")
   boolean mymethod(@PathParam("key") @WebParam(name="key") Long id);

}


@WebService (
       endpointInterface = "my.package.MyService"
   )
public class MyServiceImpl implements MyService {

   @Resource
private WebServiceContext context; // or another object of a different type allowing me to get the current servlet context.

   @Override
   boolean mymethod(Long id) {
          // doing something using the context.
   }
}

beans.xml :

...
   <jaxws:endpoint
     id="mysoapservice"
     implementor="my.package.MyServiceImpl"
     address="/soap/myservice" />
<jaxrs:server id="restfulAminService" address="/rest">
       <jaxrs:serviceBeans>
         <ref bean="myrestservice" />
       </jaxrs:serviceBeans>
   </jaxrs:server>
   <bean id="myrestservice" class="my.package.MyServiceImpl" />
...


What do you think about that? It is a usefull way to develop/declare web services, isn't it?
Priscille.


Cheers, Sergey


Hi again,
I've still my injection problem even if I move the annotation to a setter. First of all, I have duplicated my service's interface in order to have one interface dediacted to SOAP (with soap annotations) and one to REST (with rest annotation). In that (dirty) way, I have no injection problem for the soap service with :

@Resource
private WebServiceContext context;

It works fine.
But for the REST service, in order to test where is the problem, I have put this setter in my implementation class :

   private ServletContext wAppCxt;
  @Context
   public void setServletContext(ServletContext ctx) {
       System.out.println("Injecting servlet context : " + ctx);
       this.wAppCxt = ctx;
   }

While starting Tomcat with the webapp inside, I have this log :

Injecting servlet context : null

So, it seems that the injection process is called but that the context variable is null. :-(
Do you have any idea?



Sergey Beryozkin a écrit :
Hi,

Not sure what the problem is, looks like the JAX-WS injection mechanism may need some hints. Can you please try to inject WebServiceContext as a bean property instead through a setter method, with @Resource annotation movbed to the method and removed from a field and see if it helps,

Cheers, Sergey

Hi!
I have a soap web service in my webapp.
While using injection in that web service implementation class to get the current context like this :

@Resource
private WebServiceContext context;

it works fine. :-)

Now, I want the same service to be accessible via REST too. So I add some REST annotations in my code and I add in my spring config file beans.xml :
the declaration as follow :
<jaxrs:server id="restfulAminService" address="/rest/Admin">
       <jaxrs:serviceBeans>
         <ref bean="RestAminService" />
       </jaxrs:serviceBeans>
   </jaxrs:server>
   <bean id="RestAminService" class="my.package.AdminServiceImpl" />
  and while starting the server I get this error :
15 oct. 2008 16:22:35 org.apache.cxf.common.injection.ResourceInjector visitField
INFO: failed to resolve resource my.package.AdminServiceImpl/context

Why?



--

---------------------------------------------
Priscille DURVILLE

INRIA
Equipe Edelweiss (ex Acacia)

[EMAIL PROTECTED]

Tél : 01 39 63 52 77 (Paris - Rocquencourt)
Tél : 04 92 38 50 23 (Sophia Antipolis)
Fax : 04 92 38 77 83

I.N.R.I.A.
Unité de Recherche Sophia-Antipolis
2004 route des Lucioles - B.P. 93
06902 Sophia-Antipolis Cedex
FRANCE
---------------------------------------------



--

---------------------------------------------
Priscille DURVILLE

INRIA
Equipe Edelweiss (ex Acacia)

[EMAIL PROTECTED]

Tél : 01 39 63 52 77 (Paris - Rocquencourt)
Tél : 04 92 38 50 23 (Sophia Antipolis)
Fax : 04 92 38 77 83

I.N.R.I.A.
Unité de Recherche Sophia-Antipolis
2004 route des Lucioles - B.P. 93
06902 Sophia-Antipolis Cedex
FRANCE
---------------------------------------------

Reply via email to