具有路径参数的SoapUI REST Web服务模拟 [英] SoapUI REST webservice mock with path parameters

查看:111
本文介绍了具有路径参数的SoapUI REST Web服务模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为SoapUI上的POST方法创建一个模拟Web服务.我创建了一个REST项目,然后创建了MockService,MockAction并定义了一些响应和资源路径.如果我定义了相对于我的Service的固定常规路径,则效果很好,例如要在http://localhost:8080/method/post处调用的方法/后方法,它会很好地工作.

I am trying to create a mock webservice for a POST method on SoapUI. I made a REST Project, then created a MockService, a MockAction and defined a couple responses and resource paths. It works fine if I define a fixed regular path relative to my Service, for example method/postmethod to be invoked at http://localhost:8080/method/post, it works well.

但是,我想用路径参数定义我的方法,例如:http://localhost:8080/method/{par1}/{par2}/{par3}/post.我们要测试的应用程序(将调用我们的模拟服务)广泛使用这种类型的参数,因此我们不能仅为每种可能的组合创建一个方法.

What I want to do, however, is define my method with path parameters, such as this: http://localhost:8080/method/{par1}/{par2}/{par3}/post. The application we want to test, which will be invoking our mock service, uses this type of parameter extensively, so we cannot just create one method for each possible combination.

是否可以使用这种类型的path参数定义模拟POST方法?是否可以解析参数并将其用于输出响应?如果是,那怎么办?

Is it possible to define a mock POST method with that type of path parameter? Is it possible to parse the parameters and use them in the output response? If yes, then how?

推荐答案

请在响应模拟请求时启用脚本方法,soapui发布了一个默认脚本,该脚本说明了如何访问路径参数,标头, 身体 .请使用附带图片的图片作为参考.

Please enable the script method in responding the request that came to mock, there is a default script posted by soapui , which tells how to access the path parameters, headers, body . please use that , attached the pic for reference.

这篇关于具有路径参数的SoapUI REST Web服务模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆