简体   繁体   English

使用javax.xml.ws.Endpoint公开Java Web服务的局限性?

[英]Limitations of exposing Java web services using javax.xml.ws.Endpoint?

I am trying to expose some Java web services so that I can interoperate from C# (see this SO question ). 我试图公开一些Java Web服务,以便我可以从C#进行互操作(参见这个SO问题 )。 The proof of concept code below works great with WCF! 下面的概念证明代码适用于WCF!

My question is about the use of the javax.xml.ws.Endpoint class to publish my service: 我的问题是使用javax.xml.ws.Endpoint类来发布我的服务:

  1. What do I forfeit by going this route instead of a full-blown application server? 通过这条路线而不是成熟的应用服务器,我会放弃什么?
  2. Is this an appropriate solution for long-running service with a low volume of calls? 对于长时间运行的呼叫,这是一个适当的解决方案吗?

The following produces WSDL, is cleanly callable from .Net, and performs well. 以下产生WSDL,可以从.Net中干净地调用,并且运行良好。 Why wouldn't I use it? 我为什么不用它呢?

@javax.jws.WebService
public class TestSvc { 
    @javax.jws.WebMethod()
    public String sayHello() {
        return "Hello!";
    }
}

import javax.xml.ws.Endpoint;
public class Main  {
    public static void main(String[] args) throws Exception {
        Endpoint.publish("http://localhost:8181/Test", new TestSvc());
    }
}

Often the scalability arguments (thread pools etc) are quite forceful, but you've already discounted those. 通常,可伸缩性参数(线程池等)非常有用,但您已经打了折扣。

Next, reliability. 接下来,可靠性。 Some App Servers have nice clustering capabilities, very easy to add new instances, hence enabling fault tolerance while enabling a consolidated administrative view. 某些应用服务器具有良好的群集功能,非常容易添加新实例,从而在启用统一管理视图的同时实现容错。

Ease of administration generally is quite handy as your number of services grows. 随着您的服务数量的增长,易于管理通常非常方便。

Security infrastructures and declarative security models can be quite important. 安全基础架构和声明性安全模型非常重要。

For me, the whole Java EE programming model is worth having when your business logic becomes non-trivial. 对我来说,当您的业务逻辑变得非常重要时,整个Java EE编程模型是值得拥有的。 Now we could get into the whole EJB v Spring v ... debate. 现在我们可以进入整个EJB v Spring v ...辩论。 But the general point I want to make is that as your business logic gets more serious you need facilities such as thread management, persistence, connection pooling, messaging, caching and scheduling; 但我想说的一点是,随着业务逻辑变得越来越严重,您需要诸如线程管理,持久性,连接池,消息传递,缓存和调度等工具; stuff you find in App Servers. 你在App Servers中找到的东西。 Some of that comes naturally in EJB3+JPA, or Spring, some as a natural add-on in the App Servers. 其中一些在EJB3 + JPA或Spring中很自然,有些作为App Server中的自然附件。 If you have prospects of doing serious enterprise-scale Java development it may be better to buy into a little more complextity now in order to get onto an extensible basis for the future. 如果您有进行严肃的企业级Java开发的前景,那么为了获得未来可扩展的基础,现在可以更好地购买更多的互补性。

Besides losing the benefits of an application server in general, you may lose the ability to manage and administer and test the service if you were to use an application server. 除了一般地丢失应用程序服务器的好处之外,如果您要使用应用程序服务器,则可能会失去管理,管理和测试服务的能力。

In the inter-op side, you would not be able to extract a WSDL without the java call. 在操作间方面,如果没有java调用,您将无法提取WSDL。 If your new service executed something when it was published, you may have to design around that. 如果您的新服务在发布时执行了某些操作,您可能必须围绕它进行设计。 If you plan to use WCF or something similar to consume the WSDL, there are some quirks in the VS side that you have to work around when generating the service clients (the quirks don't happen every generation, but they do happen from time to time.) 如果您计划使用WCF或类似的东西来使用WSDL,那么在生成服务客户端时,您必须解决VS方面的一些怪癖(每一代都不会发生这种怪癖,但它们确实会发生在时间。)

A long-running service (I assume in other words you mean a service expected to run indefinitely) would just have to be managed as a process. 长期运行的服务(我假设您的意思是预期无限期运行的服务)只需要作为一个过程进行管理。 Depending on your design and requirements, you would have to think about starting and stopping the process, pausing it, etc. 根据您的设计和要求,您必须考虑启动和停止流程,暂停流程等。

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

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