How to create simple web service that can be used by Mobile application (Android/iPhone Apps) using java.
Please suggest the solution.
How to create simple web service that can be used by Mobile application (Android/iPhone Apps) using java.
Please suggest the solution.
The most simple web service in Java would be basically any class annotated with @Webservice
and published via the Endpoint
class.
As an example, an implementation that echo's a String:
@WebService
public class EchoService {
public String echoHello(String name) {
return "Hello " + name;
}
}
You can publish that on localhost via:
EchoService service = new EchoService();
Endpoint.publish("http://localhost:2000/echo", service);
This will publish a SOAP endpoint with document/literal binding. For more information, see the JAX-WS tutorial.