-1

我想知道如何创建网络服务。我是一名安卓开发者。哪种方法适用于 android web 服务,实际上我们在 PostgreSQL 中使用服务器端 apache tomcat 所以请给我关于这个问题的任何想法

4

2 回答 2

4

Presuming that by "web service" you mean one of the most common methods currently used, REST-style HTTP+JSON or HTTP+XML, you probably want to use JAX-RS (JSR311). This is part of the Java EE specification, and the easiest way to get going is to just use JBoss AS 7 which bundles it. JAX-RS implementations are also easy to use with Tomcat if you prefer Tomcat. You want RESTEasy or Jersey; either should be fine. Check out the Java EE tutorial for JAX-RS, the Jersey getting started guide, and the RESTEasy documentation.

If, in fact, you want some other kind of web service like XML-RPC, SOAP or CORBA (edit: as your post tags suggest), then (a) reconsider, they're being superceded for a reason and (b) if you must use them, look into implementations specific to the binding technology you must use. I'd suggest that you examine JAX-WS for SOAP+WSDL, but I haven't worked with it myself so I have nothing further to offer. I know the NetBeans IDE offers some kind of old-school SOAP/JAX-WS web services support, but again haven't looked into it.

I expect it'll be way easier to work with JAX-RS in Android than it will be to work with SOAP. A JAX-RS client doesn't need to be anything more than a HTTP client library and an XML or JSON parser/writer - though client libraries that target REST-style APIs exist and make them even easier to work with.

Do you really need SOAP? Or do you just need any kind of web based client/server communication? What exactly are you trying to achieve with this? Where does PostgreSQL come into it?

于 2012-05-17T12:54:57.010 回答
0

我不完全确定这里要问什么,我发现这个问题现在很可能会被关闭,但是这里有。

如果您在 Android 中实现 SOAP 客户端时遇到问题,请参阅Stack Overflow 中的这个问题。投票率最高的答案表明 Android 没有任何本机 SOAP 库,但您可以使用类似kSOAP 2的东西。

如果困扰您的是服务器部分,请参阅本教程。这是一篇冗长的文章,并且严重依赖图像,所以我什至不会尝试对其进行总结。尝试使用那里(和其他地方)提供的说明来实施您的服务,一旦您有一些代码要向我们展示,请返回 Stack Overflow。

于 2012-05-17T10:52:05.503 回答