You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取SOAP UI项目中请求所使用的全部URI?

获取SOAP UI项目中所有请求URI的方法

方法一:用Groovy脚本批量提取(高效推荐)

SOAP UI内置Groovy支持,能快速遍历所有请求并提取URI:

  1. 打开目标项目,要么在某个测试用例下新建Groovy Script测试步骤,要么直接打开顶部菜单栏的Script Console
  2. 粘贴以下代码并执行:
// 获取当前项目实例
def project = context.testCase?.testSuite?.project ?: com.eviware.soapui.SoapUI.getActiveWorkspace().getActiveProject()

// 遍历测试套件->测试用例->请求步骤
project.testSuites.each { suiteName, suite ->
    suite.testCases.each { caseName, testCase ->
        testCase.testSteps.each { stepName, step ->
            // 匹配SOAP和REST请求步骤
            if (step in [com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep, 
                         com.eviware.soapui.impl.rest.teststeps.RestTestRequestStep]) {
                def req = step.testRequest
                def fullUri = req.endpoint + req.path
                println "请求: ${stepName} | URI: ${fullUri}"
            }
        }
    }
}

// 处理项目根目录下的独立请求(非测试用例内的请求)
project.interfaceList.each { iface ->
    iface.operations.each { op ->
        op.requests.each { req ->
            def fullUri = req.endpoint + req.path
            println "独立请求: ${req.name} | URI: ${fullUri}"
        }
    }
}
  1. 执行后,控制台会输出所有请求的名称和对应完整URI,直接复制结果即可。

方法二:导出XML后手动/正则提取(适合小型项目)

如果不想写脚本,可以通过导出项目文件解析:

  • 右键项目名称,选择Export Project,导出为XML格式
  • 用文本编辑器打开XML文件,查找<endpoint>和<path>标签,两者拼接就是完整URI
  • 也可以用正则表达式批量匹配,比如用endpoint="([^"]+)"提取端点,path="([^"]+)"提取路径,再组合。

注意事项

  • 如果项目使用了环境变量(比如${#Project#Endpoint}),脚本会自动解析为当前激活环境的实际地址
  • 脚本兼容SOAP和REST类型的请求步骤

内容的提问来源于stack exchange,提问作者Srikanth Gade

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 09:03:48