Java 在 Eclipse 中使用和测试 Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2092083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 03:26:39  来源:igfitidea点击:

Using and testing web services in Eclipse

javaeclipseweb-services

提问by EugeneP

Can you tell the BEST way how to test & use Web Services in Eclipse ?

您能说出如何在 Eclipse 中测试和使用 Web 服务的最佳方式吗?

I had little experience with web services, that is, I used an Apache Axis plugin that generated the client stub.

我对 Web 服务几乎没有经验,也就是说,我使用了一个 Apache Axis 插件来生成客户端存根。

I do not need to write my own web services right now, only use existing ones. I have Eclipse Java EE, I can download any plugin. What would you suggest?

我现在不需要编写自己的 Web 服务,只使用现有的服务。我有 Eclipse Java EE,我可以下载任何插件。你有什么建议?

采纳答案by Pascal Thivent

To test web services, the best tool is IMHO soapUIwhich is available as an eclipse pluginand is superior by far to any other tool I've used.

要测试 Web 服务,最好的工具是 IMHO soapUI,它可以作为Eclipse 插件使用,并且远远优于我使用过的任何其他工具。

To use web services, it's worth noting that Eclipse has now a JAX-WS Tools Project(in the Web Tools Incubator) which is using the Apache CXF implementation (please, let Axis 2 die).

要使用 Web 服务,值得注意的是 Eclipse 现在有一个JAX-WS 工具项目(在Web 工具孵化器中),它使用 Apache CXF 实现(请让 Axis 2 消亡)。

To install this project, point your Eclipse update site manager to The Eclipse Web Tools Platform (WTP) Project update site - http://download.eclipse.org/webtools/updates. When you access the update site, you should see the CXF Web Services (Incubator)feature available in the listing:

要安装此项目,请将 Eclipse 更新站点管理器指向Eclipse Web 工具平台 (WTP) 项目更新站点 - http://download.eclipse.org/webtools/updates。当您访问更新站点时,您应该会在列表中看到可用的CXF Web 服务(孵化器)功能:

alt text

替代文字

Once installed and configured (Window > Preferences... > Web Services > CXF 2.x Preferences), you will be able to use the CXF runtime to test web services (and / or to create a CXF Web Services Project, see image below even if this is not your first goal).

安装和配置后(Window > Preferences... > Web Services > CXF 2.x Preferences),您将能够使用 CXF 运行时来测试 Web 服务(和/或创建CXF Web 服务项目,见下图即使这不是您的第一个目标)。

alt text
(source: corneliadavis.com)

替代文字
(来源:corneliadavis.com

You will find some video clips showing you how to create and deploy Bottom-Up and Top-Down Web services using JAX-WS Tools here.

您将在此处找到一些视频剪辑,向您展示如何使用 JAX-WS 工具创建和部署自下而上和自上而下的 Web 服务 。

回答by VonC

Your Java EE Eclipse already includes WTP (Web Tool Platform), so you shouldn't download another plugin.

您的 Java EE Eclipse 已经包含WTP (Web Tool Platform),因此您不应下载其他插件。

All you need now is to follow one of those tutorials

您现在需要的只是遵循其中一个教程



WTP:

支付意愿:

The Eclipse Web Tools Platform (WTP) project extends the Eclipse platform with tools for developing Web and Java EE applications

Eclipse Web 工具平台 (WTP) 项目通过用于开发 Web 和 Java EE 应用程序的工具扩展了 Eclipse 平台

It includes a web services sectionwith 2 components:

它包括具有 2 个组件的Web 服务部分

  • The JST Web services component contains tools for developing and interacting with Java Web services.
  • The WST Web services component contains tools for Web services development which is not Java specific.
  • JST Web 服务组件包含用于开发 Java Web 服务并与之交互的工具。
  • WST Web 服务组件包含非 Java 特定的 Web 服务开发工具。

回答by Nicolas Raoul

Add the WSDL file to the root of an Eclipse project, right-click on it, select "Web Services" and "Generate client", set the cursor to "Assemble" and Eclipse will generate the Java code that will allow you to communicate with the Web Service.

将 WSDL 文件添加到 Eclipse 项目的根目录,右键单击它,选择“Web Services”和“Generate client”,将光标设置为“Assemble”,Eclipse 将生成允许您与之通信的 Java 代码网络服务。

回答by kgiannakakis

I believe that the easiest way to test web services with Eclipse is the Axis2 plug-in, which is bundled in the Java EE edition. Here is an articleabout it. It focuses on services and not clients, but it is even easier if you already have a running service and want to create a client.

我相信使用 Eclipse 测试 Web 服务的最简单方法是 Axis2 插件,它捆绑在 Java EE 版本中。这是一篇关于它的文章。它专注于服务而不是客户端,但如果您已经有一个正在运行的服务并想要创建一个客户端,那就更容易了。

回答by Roland Tepp

Take a look at Eclipse Swordfish project.

看一看Eclipse Swordfish 项目

From it's home page:

从它的主页:

The goal of the Swordfish project is to provide an extensible SOA framework based on the proven Eclipse Equinox runtime technology. The framework is designed to be complemented by additional open source components such as a service registry, a messaging system, a process engine etc. to form a comprehensive open source SOA runtime environment based on both established and emerging open standards.

Swordfish 项目的目标是提供一个基于经过验证的 Eclipse Equinox 运行时技术的可扩展 SOA 框架。该框架旨在通过额外的开源组件(例如服务注册表、消息传递系统、流程引擎等)进行补充,以形成基于既定和新兴开放标准的全面开源 SOA 运行时环境。

回答by Brian

Axis2 plug-in works fine for creating a testing a web service through a WSDL. I've only tested a simple SOAP web service this way in Eclipse.

Axis2 插件非常适合通过 WSDL 创建测试 Web 服务。我只在 Eclipse 中以这种方式测试了一个简单的 SOAP Web 服务。

What I have not been able to do myself is create another project for example a Dynamic Web App project and create a client WSDL from that web service. I could copy the WSDL into my new project but that would be silly. Realistically we don't copy a WSDL we generate one based on the web service WSDL but through a registered address that points to that web service.

我自己无法做的是创建另一个项目,例如动态 Web 应用程序项目,并从该 Web 服务创建客户端 WSDL。我可以将 WSDL 复制到我的新项目中,但这很愚蠢。实际上,我们不会复制基于 Web 服务 WSDL 生成的 WSDL,而是通过指向该 Web 服务的注册地址。

I have read up a little on the CXF option and thought that I had added what I needed to use it. So far I have not seen any of the web service options in Eclipse with the exception of creating and testing a web service in the same project which to me is of little or no use.

我已经阅读了一些关于 CXF 选项的内容,并认为我已经添加了使用它所需的内容。到目前为止,我还没有在 Eclipse 中看到任何 Web 服务选项,除了在同一个项目中创建和测试一个 Web 服务,这对我来说几乎没有用处。