如何使用 java 创建可供移动应用程序(Android/iPhone 应用程序)使用的简单 Web 服务。
请提出解决方案。
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.