简体   繁体   English

作为Web服务运行的Java应用程序与Glassfish上的Java EE应用程序进行通信

[英]Java Application running as web service communicating with Java EE app on Glassfish

I have a stand alone Java application that needs to get information (string data) from a Java EE application, running on a Glassfish 3.1 Application server. 我有一个独立的Java应用程序,需要从运行在Glassfish 3.1 Application服务器上的Java EE应用程序获取信息(字符串数据)。 I have created a web service for my Java app, but I'm wondering how I could achieve communication with the Java EE glass fish app (using servlet?). 我已经为我的Java应用程序创建了一个Web服务,但是我想知道如何实现与Java EE glass fish应用程序的通信(使用servlet?)。

I hope to have a method on my app that can be called from, for example, a client running on glassfish (and vice-versa). 我希望在我的应用程序中有一个方法,可以从运行在glassfish上的客户端调用该方法(反之亦然)。 This method would have something like a String array as parameter, so that I would be able to pass the data between the apps. 此方法将具有类似String数组的参数,这样我就可以在应用程序之间传递数据。

Note : I am unable to deploy my app on Glassfish, since we are trying to achieve separation till we are sure the application I am developing will not cause Glassfish to crash ( we currently have other critical apps running on Glassfish). 注意 :我无法在Glassfish上部署我的应用程序,因为我们试图实现分离,直到我们确定正在开发的应用程序不会导致Glassfish崩溃(我们目前在Glassfish上运行其他重要的应用程序)。 Also note that this is all taking place on the same machine. 另请注意,这都是在同一台计算机上进行的。

Have you looked at the URL class. 您是否看过URL类。 try this url Java URL example 试试这个URL Java URL示例

This may help 这可能会有所帮助

You should develop a web service and deploy it on Glassfish within your existing application. 您应该开发一个Web服务并将其部署在现有应用程序中的Glassfish上。 You can do this via a Servlet based web service, or a Session Bean web service, whichever is more appropriate for you. 您可以通过基于Servlet的Web服务或Session Bean Web服务(两者中最合适的一个)来执行此操作。

You will then create a web service client against that web service for your Java app, and integrate it appropriately with calls to the servers via the web service. 然后,您将针对Java应用程序针对该Web服务创建一个Web服务客户端,并将其与通过Web服务对服务器的调用适当地集成。

Of course, this should all be done against development servers, not your production servers. 当然,所有这些操作都应针对开发服务器而不是生产服务器。 Glassfish can be deployed pretty much anywhere: your machine, another machine, a VM, in "the cloud". Glassfish几乎可以部署在任何地方:“云”中的计算机,另一台计算机,VM。 Not having a development server available for, well, development is unacceptable . 没有开发服务器可用于开发,这是不可接受的 There is no way you can determine if your app will "crash Glassfish" unless you can test it. 除非您可以对其进行测试,否则无法确定您的应用程序是否会使“ Glassfish”崩溃。

To quote the esteemed Donald Knuth: "I have only proved it correct, not tried it." 引用尊敬的唐纳德·纳斯(Donald Knuth)的话:“我只是证明它是正确的,没有尝试过。”

Get a test server, develop against it. 获取测试服务器,针对它进行开发。 Move forward. 往前走

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

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