Hi Priscille
Thanks for your response Sergey. So I have to wait for 2.1.3... a long time?
O:-)
Unless Willem can somehow pick up the update I just commited without breaking
the release process,
then yes (it'll be 2.1.4), sorry :-). But hopefully what Ian just suggested can work for you too, or may be you can do the parameter
based context injection.
<snip/>
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).
Hmm... I thought it shouldn't be an issue at all
So, what you're saying is that @Path and @GET annotations are not inherited ?
Let me give it a try...
@WebService
@Path("/myservice/")
public interface MyService {
@WebMethod
@GET
@Path("/{key}")
boolean mymethod(@PathParam("key") @WebParam(name="key") Long id);
}
-2- The second point is that when I declare my service to be accessible both with SOAP and REST, the WebServiceContext injection
never happens.
This is strange too. Looks like JAXWS runtime is confused a bit by the presence of the JAX-RS annotations, I'll need to look into
it.
<snip/>
-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?
Yes, I agree. We'll make it work
Cheers, Sergey
Priscille.