This content has been marked as final.
Show 3 replies
-
1. Context root of EJB @WebService in WAR
nickarls Feb 9, 2011 4:15 PM (in response to sejersbol)Does it react to @WebContext.contextRoot ?
-
2. Re: Context root of EJB @WebService in WAR
sejersbol Feb 10, 2011 12:40 AM (in response to nickarls)I have tried:
package com.example; import javax.ejb.Stateless; import javax.jws.WebMethod; import javax.jws.WebService; import org.jboss.wsf.spi.annotation.WebContext; @Stateless @WebService @WebContext(contextRoot = "/webservices") public class Ws { private String message = new String("Hello, "); @WebMethod public String sayHello(String name) { return message + name + "."; } }
But it does not change a thing, I still get endpoint http://localhost:8080/ws-1.0.0-SNAPSHOT/Ws ... Maybe this is a bug in AS 6?
-
3. Re: Context root of EJB @WebService in WAR
sejersbol Feb 10, 2011 7:55 AM (in response to sejersbol)Don't know if you can call it a solution to the problem, maybe more of a workaround. The following works:
Instead of setting @WebService on the @Stateless, intect the local bean in the web service:
@WebService public class Ws { @Inject SpeakQuery bean; @WebMethod public String sayHello(String name) throws Exception { return bean.sayHello(name); } }
Where SpeakQuery and SimpleSpeakQuery would look like this:
public interface SpeakQuery { public String sayHello(String name) throws Exception; } @Stateless public class SimpleSpeakQuery implements SpeakQuery { private String message = new String("Hello, "); public String sayHello(String name) throws Exception { return message + name + "."; } }
With the above you get it all - nice web service with context root configured in jboss-web and transactions.