Summary of implementing a webservice on Ubuntu Lucid
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk
In Eclipse create the following code:
package milesd;
import javax.xml.ws.Endpoint;
import milesd.GreetingImpl;
public class WSPublisher {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/WS/Greeting",
new GreetingImpl());
}
}
------
package milesd;
import javax.jws.WebService;
@WebService(endpointInterface = "milesd.Greeting")
public class GreetingImpl implements Greeting {
@Override
public String sayHello(String name) {
return "Hello, Welcome to jax-ws " + name;
}
}
------
package milesd;
import javax.xml.ws.Endpoint;
import milesd.GreetingImpl;
public class WSPublisher {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/WS/Greeting",
new GreetingImpl());
}
}
------
Generate client stubs (by using wsimport):
CD to your source directory.
wsimport -keep -verbose http://localhost:8080/WS/Greeting?wsdl
This will generate relevant client stubs. Remove the .class files
------
Create the following client code:
package milesd;
import milesd.Greeting;
import milesd.GreetingImplService;
public class Client {
public static void main(String[] args) {
GreetingImplService service = new GreetingImplService();
Greeting greeting = service.getGreetingImplPort();
System.out.println("------->> Call Started");
System.out.println(greeting.sayHello("milesd"));
System.out.println("------->> Call Ended");
}
}
wsimport -keep -verbose http://localhost:8080/WS/Greeting?wsdl