Wiremock soapXPath 处理程序 text() 什么都不返回

问题描述 投票:0回答:0

我使用 Wiremock 进行了 Junit 5 测试,我尝试根据 SOAP 请求中元素的值选择 Wiremock 将提供的响应文件。但是我在使用

text()
功能时遇到了困难。

这里有一些细节:

线控设置

@RegisterExtension
    static WireMockExtension wireMockServer = WireMockExtension.newInstance()
            .options(wireMockConfig()
                    .dynamicPort()
                    .extensions(new ResponseTemplateTransformer(true)))
            .build();

Wiremock 存根

wireMockServer.stubFor(WireMock.post(urlPathEqualTo("/personRecords"))
                .willReturn(ok()
                        .withBodyFile("wiremock/response/{{soapXPath request.body '/GetPersonsForProfile/personId/extension/text()'}}.xml")));

SOAP 请求结构

<!--Showing just the body for brevity-->
<soapenv:Body>
   <urn1:GetPersonsForProfile>
      <urn1:personId>
         <urn2:root>1.1.1.1</urn2:root>
         <urn2:extension>197001011111</urn2:extension>
      </urn1:personId>
   </urn1:GetPersonsForProfile>
</soapenv:Body>

我收到以下错误:

Error 500 java.io.FileNotFoundException: /path-to-folder/__files/wiremock/response/.xml (No such file or directory)

在试验时,我尝试从存根定义中删除

/text()
,但我得到了这个错误:
Error 500 java.io.FileNotFoundException: /path-to-folder/__files/wiremock/response/&lt;extension&gt;197001011111&lt;/extension&gt;.xml (No such file or directory)
这告诉我它在请求中找到了元素,但
text()
由于某种原因不起作用。

有什么想法吗?

xpath soap junit wiremock
© www.soinside.com 2019 - 2024. All rights reserved.