HelloWorld EJB3-WebService
ernie2705 May 4, 2006 4:30 AMHi! I´m new to JBoss and also my experience with developing Web Services are reduced to some auto-generating stuff in Netweaver. So I had a look at some internet-pages and found the new features of ejb3 and JBossWS. So I tried to start with a simple HelloWorld EJB + WebService:
HelloWorldBean:
@Stateless
@WebService(
name="EndpointInterface",
targetNamespace="http://facade.charon/jaws",
serviceName="HelloWorldService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@Remote(HelloWorldRemoteInterface.class)
public class HelloWorldBean implements HelloWorldRemoteInterface {
public static final String RemoteJNDIName = HelloWorldBean.class
.getSimpleName()
+ "/remote";
@WebMethod
public String getHello() {
return "HelloWorld";
}
}
HelloWorldRemoteInterface:
public interface HelloWorldRemoteInterface {
@WebMethod
public String getHello();
}
Client:
...
URL url = new URL("http://localhost:8080/hello/HelloWorldBean?wsdl");
QName qname = new QName("http://facade.charon/jaws",
"HelloWorldService");
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(url, qname);
HelloWorldRemoteInterface hw = (HelloWorldRemoteInterface) service
.getPort(HelloWorldRemoteInterface.class);
System.out.println(hw.getHello());
...
Compiling and deploying works fine, JBoss says WebService started. But when I try to connect via client code, I get following exception within JBoss:
10:20:40,960 ERROR [SOAPFaultExceptionHelper] SOAP request exception
javax.xml.rpc.soap.SOAPFaultException: Endpoint {http://facade.charon/jaws}EndpointInterfacePort does not contain operation meta data for: {http://schemas.xmlsoap.org/soap/envelope/}Envelope
on Client side this results to:
Exception in thread "main" java.lang.ClassCastException: org.jboss.ws.soap.SOAPMessageImpl
The exeption is thrown in following line: System.out.println(hw.getHello());
Can somebody help me? Maybe somebody can give me a link to a tutorial which contains such an example?
Thx,
Ernie