简体   繁体   English

开发Web服务的最佳实践Java技术?

[英]Best practice Java technology for developing web services?

Could someone please recommend a suitable FOSS Java technology for developing a webservice with these requirements: 有人可以推荐适合的FOSS Java技术来开发具有以下要求的Web服务:

Needs to query an Oracle database, return XML data, and support rollbacks (so probably would have to maintain state in some way). 需要查询Oracle数据库,返回XML数据并支持回滚(因此可能必须以某种方式维护状态)。

Currently I have a webservice written in PHP, but I've found PHP's support for SOAP limiting. 当前,我有一个用PHP编写的Web服务,但是我发现PHP支持SOAP限制。 I've looked at the various Sun Microsystems pages about their webservice offerings but find it baffling to choose between them. 我已经看过有关Sun Websystem产品的各种页面,但是在它们之间进行选择感到困惑。 If someone could recommend a suitable direction it would be very useful. 如果有人可以推荐合适的方向,那将非常有用。

Your service will have a hard time if it maintains state. 如果您的服务保持状态,将很难。

The very fact that you describe it in terms of an Oracle database and transactions indicates trouble. 您用Oracle数据库和事务来描述它的事实表明存在麻烦。 Start with the "service" that the component will provide and think in terms of the interface - the messages in and out. 从组件将提供的“服务”开始,并根据界面(消息的进出)进行思考。 If you get those right you won't have any problem. 如果您做对了,就不会有任何问题。

You're going to have to make a SOAP versus REST decision. 您将不得不做出SOAP与REST的决定。

If you decide to go in the SOAP direction, I think the best way to develop web services is to use Spring's "contract first" web service approach. 如果您决定朝SOAP方向发展,我认为开发Web服务的最佳方法是使用Spring的“合同优先” Web服务方法。 You'll start with an XSD for the messages and work from there. 您将从消息的XSD开始,然后从那里开始工作。 You aren't tied to an app server that way. 您不会以这种方式绑定到应用服务器。 It's especially good if you happen to be using Spring already. 如果您碰巧已经在使用Spring,那就特别好。 It can help with connecting to the database and declarative transactions as well. 它也可以帮助连接到数据库和声明性事务。

In general, web services (SOAP or REST) are stateless. 通常,Web服务(SOAP或REST)是无状态的。 Transaction handling would generally occur inside the service itself. 事务处理通常会在服务本身内部进行。 If the work completed successfully, a "good" response is returned and changes are committed. 如果工作成功完成,则返回“良好”响应并提交更改。 If the work failed, the work is rolled back and an "error" response is given. 如果工作失败,则会回滚工作并给出“错误”响应。

For strictly the web service portion, I recommend AXIS (either 1 or 2). 对于严格的Web服务部分,我建议使用AXIS(1或2)。 They are well supported Apache projects which have plugins for Eclipse and other IDEs. 它们是受良好支持的Apache项目,具有用于Eclipse和其他IDE的插件。 I don't use the Spring Framework, but I hear it's great for tying all the bits of your service together (database, web service, configuration, etc). 我不使用Spring框架,但是我听说它非常适合将服务的所有部分(数据库,Web服务,配置等)捆绑在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM