模拟 Web 服务响应 |将其中几个捆绑在网络应用程序中

发布于 2024-08-15 13:11:20 字数 369 浏览 3 评论 0原文

我正在一个企业项目中工作,我的团队负责创建应用程序的前端,还有另一个团队开发 Web 服务,并为将作为该项目的一部分提供的所有服务提供 WSDL。在开发阶段,我们的本地开发环境将指向负责创建 Web 服务的团队的开发箱之一。他们的开发环境很可能在迭代过程中不稳定。为了减轻这种风险,我们在本地计算机上使用 SOAP UI 并启动模拟服务并进行开发。每当我们需要不同风格的响应时,我们都会修改本地服务响应 XML。这个过程运行良好,但我想知道是否有一种方法,对于每个服务来说,我创建 10 个响应,并将它们部署为一台机器上的 tomcat 战争,而我的整个开发团队指出该战争将暴露相同的内容服务,并且基于参数,它可以发送战争中捆绑的 10 个响应中的一个响应。我不想为此花费任何精力。是否有一个工具可以提供这种开箱即用的功能。

I am working in an enterprise project and my team is responsible for creating front end of the application and there is another team developing webservices and has provided WSDL for all the services that will be available as part of this project. In development phase our local dev environment will point to one of the development box of the team responsible for creating web services. It is quite possible that their dev environment will be shaky in middle of iteration. In order to mitigate that risk, we are using SOAP UI on our local machine and start mocked service and do the development. Whenever we need different flavors of response we modify the local service response XML. This process is running good but i was wondering if there is a way that for each service say i create 10 responses and deploy them as a war on tomcat on one of the machine and my whole development team points to that war which will expose the same service and based on a parameter it can send one response out of the 10 responses bundled in war. i don't want to spend any effort on this. Is there a tool which provides this kind of functionality out of the box.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

权谋诡计 2024-08-22 13:11:20

如果你稍微分解一下你的内部架构,这会让你的生活更轻松。与其不灵活地让客户端代码依赖于外部 SOAP 服务,不如定义一个供内部使用的接口。您可以将此称为 IServiceProxy 或类似的名称。

让客户端代码与该接口对话,并使用依赖注入 (DI) 将其实例注入客户端。这意味着对于很多开发用途,您可以简单地用 Test Double(例如 Mock)替换该接口。

如果您还必须有一个 SOAP 服务来验证您的 SOAP 堆栈是否按预期工作,请注意所谓的共享夹具测试气味。单个服务器上的共享“测试”服务将是共享夹具,它可能会给您带来更多的麻烦,因为开发人员会互相超越,这将成为瓶颈。

更好的替代方案是在每个开发人员的计算机上设置 SOAP 服务,或者,如果不可能的话,为每个开发人员设置专用服务。

您可以在优秀的 xUnit 中阅读有关共享夹具以及许多其他测试模式和反模式的更多信息测试模式

It would make your life easier if you split up your internal architecture a bit. Instead of inflexibly letting the client code rely on an external SOAP service, it would be beneficial to define an interface for internal use. You could call this IServiceProxy or some such name.

Let the client code talk to that interface and use Dependency Injection (DI) to inject an instance of it into the client. This means that for a lot of development usage, you can simply replace this interface with a Test Double (e.g. a Mock).

If you must also have a SOAP service to verify that your SOAP stack works as intended, watch out for the so-called Shared Fixture test smell. A shared 'test' service on a single server would be a Shared Fixture, and it is likely to give you more trouble than it's worth because developers would be stepping over each other and it would be a bottleneck.

A better alternative is to set up a SOAP service on each developer's machine, or, if that's not possible, a dedicated service for each developer.

You can read more about Shared Fixtures and many other test patterns and anti-patterns in the excellent xUnit Test Patterns.

空城仅有旧梦在 2024-08-22 13:11:20

我处于同样的情况,测试团队想要测试不同的场景,这需要不时修改模拟服务。由于大多数测试团队人员都是非技术人员,因此我总是费心去更新soapUI 模拟套装。为了避免这种情况,我创建了一个完全基于 Web 的应用程序来使用 WSDL 模拟服务。由于它完全基于网络,测试人员能够从他们的网络浏览器更改模拟服务。

该应用程序是在soapUI 框架之上编写的。它提供自动生成虚拟响应 SOAP 消息和验证等功能。该实用程序还允许延迟模拟服务,这有助于性能测试。

我现在已将该应用程序添加到 SourceForge。请在下面的链接中找到

http://sourceforge.net/projects/easymocker/

(Web Service Mocker 是一个易于使用、完全基于 Web 的 SOAP Web 服务模拟实用程序,该实用程序在 SOA 开发环境中的单元测试、组件集成测试和非功能需求测试中非常有用。)

I was in the same situation where testing team wanted to test different scenario, which required mocked service to be modified time to time. Since most of the testing team personal were non technical, I was always bothered to update the soapUI mock suit. To avoid this I created a completely web based a application to mock a service using WSDL. Since it is completely web based testers were able to change the mocked service from their web browsers.

The application is written on top of soapUI framework. It provides features like auto generate dummy response SOAP message and validation etc. The utility also allows to mock a service with delay, this helps for performance testing.

I've now added the application to SourceForge. Please find in below link

http://sourceforge.net/projects/easymocker/

(Web Service Mocker is an easy to use, completely web based SOAP web service mocking utility. This utility is found very useful in a SOA development environment during unit test, component integration test and non-functional requirement testing.)

谎言 2024-08-22 13:11:20

我之前遇到过类似的问题

我们使用 WSDL 创建了一个模拟主机 Web 服务应用程序,该应用程序需要模拟服务将

所有不同的响应存储在服务器中的不同 XML 文件中

在 Web 服务代码中,我们只需在 Web 服务请求中放置带有唯一标识符的开关,然后在 switch 块内,我们从存储在服务器中的与唯一标识符相对应的特定 XML 文件发送响应

这是可能的,因为响应大部分是静态的,并且会根据请求中的单个唯一标识符而变化

构建和部署几乎花了一天的时间这是因为我们有方便的回复

希望这可以根据您的应用程序上下文对您有所帮助

I faced the similar problem earlier

We created a mock host web service application using the WSDL for which mock service is required

Stored all different responses in different XML files in server

In web service code we just put switch with unique identifier in the Web Service request and inside switch block we are sending the response from the specific XML file stored in server corresponding to unique identifier

This was possible as the Response were mostly static and will vary with respect to single unique identifier in the request

It took hardly a day to build and deploy this as we had responses handy

Hope this helps you based on the context of your application

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文