如何创建简单的Web服务 [英] How to create Simple web service
本文介绍了如何创建简单的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建可以使用Java移动应用(Android版/ iPhone应用程序)可以使用简单的Web服务。
How to create simple web service that can be used by Mobile application (Android/iPhone Apps) using java.
请建议的解决方案。
推荐答案
在Java中的最简单的Web服务将是基本上通过与 @WebService
注释和出版任何类端点
类。
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;
}
}
您可以通过发布在localhost:
You can publish that on localhost via:
EchoService service = new EchoService();
Endpoint.publish("http://localhost:2000/echo", service);
这将发布与文档/文字绑定一个SOAP端点。欲了解更多信息,请参阅the JAX-WS教程。
This will publish a SOAP endpoint with document/literal binding. For more information, see the JAX-WS tutorial.
这篇关于如何创建简单的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文