I'm trying to create a simple web service in eclipse. First i created an empty java project and added the three following files in the src folder
package com.alfaisaliah;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public interface Greeting {
@WebMethod
String sayHello(String name);
}
package com.alfaisaliah;
import javax.jws.WebService;
@WebService(endpointInterface="com.alfaisaliah.Greeting")
public class GreetingImp implements Greeting {
@Override
public String sayHello(String name) {
return "Hello " + name;
}
}
package com.alfaisaliah;
import javax.xml.ws.Endpoint;
public class WSPublisher {
public static void main(String[] args){
Endpoint.publish("http://localhost:8081/WS/Greeting", new GreetingImp());
}
}
The tutorial I'm following doesn't specify any server to run the web service on! I'm wondering if I need to specify any server. I already have Tomcat v5.5 but am not using it in this example. Whenever I run this project as a java project I get some kind of error. Can anyone please help me identify where my problem is trying to run the web service. Here is the output of the eclipse console
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class com.alfaisaliah.jaxws.SayHello
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class com.alfaisaliah.jaxws.SayHelloResponse
Also when I run the project again it says that the address is already in use
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass
INFO: Dynamically creating request wrapper Class com.alfaisaliah.jaxws.SayHello
Feb 26, 2012 12:01:00 PM com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class com.alfaisaliah.jaxws.SayHelloResponse
Exception in thread "main" com.sun.xml.internal.ws.server.ServerRtException: Server Runtime Error: java.net.BindException: Address already in use
I would appreciate your help guys :)
check this link out,
http://www.myeclipseide.com/documentation/quickstarts/webservices_jaxws/
Above link gives step-by-step details for generating both web-service server and client.
You start with POJO, no annotation needed, JAX-WS runtime will take care after deployment on Tomcat server.