简体   繁体   English

在Eclipse中使用和测试Web服务

[英]Using and testing web services in Eclipse

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. 我现在不需要编写自己的Web服务,只使用现有的Web服务。 I have Eclipse Java EE, I can download any plugin. 我有Eclipse Java EE,我可以下载任何插件。 What would you suggest? 你会建议什么?

To test web services, the best tool is IMHO soapUI which is available as an eclipse plugin and 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现在有一个使用Apache CXF实现的JAX-WS工具项目 (在Web Tools Incubator中 )(请让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 . 要安装此项目,请将Eclipse更新站点管理器指向Eclipse Web Tools Platform(WTP)项目更新站点 - 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: 当您访问更新站点时,您应该看到列表中提供的CXF Web服务(孵化器)功能:

替代文字

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服务项目 ,请参见下图即使这不是你的第一个目标)。

替代文字
(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工具创建和部署Bottom-Up和Top-Down Web服务。

Your Java EE Eclipse already includes WTP (Web Tool Platform) , so you shouldn't download another plugin. 您的Java EE Eclipse已包含WTP(Web工具平台) ,因此您不应下载其他插件。

All you need now is to follow one of those tutorials 您现在需要的只是遵循其中一个教程


WTP: WTP:

The Eclipse Web Tools Platform (WTP) project extends the Eclipse platform with tools for developing Web and Java EE applications Eclipse Web Tools Platform(WTP)项目使用用于开发Web和Java EE应用程序的工具扩展了Eclipse平台

It includes a web services section with 2 components: 它包括一个包含2个组件的Web服务部分

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

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. Swordfish项目的目标是基于成熟的Eclipse Equinox运行时技术提供可扩展的SOA框架。 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. 该框架旨在通过其他开源组件(如服务注册表,消息传递系统,流程引擎等)进行补充,以形成基于既定和新兴开放标准的全面开源SOA运行时环境。

Axis2 plug-in works fine for creating a testing a web service through a WSDL. Axis2插件适用于通过WSDL创建Web服务测试。 I've only tested a simple SOAP web service this way in Eclipse. 我只是在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. 我自己无法做的是创建另一个项目,例如Dynamic Web App项目,并从该Web服务创建客户端WSDL。 I could copy the WSDL into my new project but that would be silly. 我可以将WSDL复制到我的新项目中,但这很愚蠢。 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服务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. 我已经阅读了一些有关CXF选项的内容,并认为我添加了我需要使用它的内容。 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. 到目前为止,我没有在Eclipse中看到任何Web服务选项,除了在同一个项目中创建和测试Web服务对我来说很少或没有用。

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

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. 我相信使用Eclipse测试Web服务的最简单方法是Axis2插件,该插件捆绑在Java EE版本中。 Here is an article about 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. 它侧重于服务而不是客户端,但如果您已经拥有正在运行的服务并且想要创建客户端,则更容易。

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

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