Citrus-Framework:可以使用 Java DSL 从服务器模拟发送 SOAP 附件吗?
Citrus-Framework: Possible to send SOAP attachment from server simulation with Java DSL?
对于使用 Citrus Framework 的组件测试,我 模拟通过 SOAP[=29 调用的后端系统 =].
<citrus-ws:server id="backendSimulationServer"
port="8080"
auto-start="true"
interceptors="serverInterceptors"
timeout="5000"/>
我从组件获取 SOAP 请求并发回响应。
runner.receive(action -> action.endpoint("backendSimulationServer")
.name("search-request")
.payload(new ClassPathResource("testfiles/search-request-expectation.xml"))
);
runner.send(action -> action.endpoint("backendSimulationServer")
.name("search-response")
.payload(new ClassPathResource("testfiles/search-response.xml"))
);
但现在我必须用 MTOM 附件响应 来回答请求。我发现在 soap().client()
上使用 .attachment
的柑橘示例,但 .attachment
不适用于我的服务器模拟。
这可以用 Java DSL 实现吗?还是我要用 XML DSL 重写测试用例来实现这个?
SOAP 附件和启用 MTOM 的方法在 Citrus 的服务器组件上也可用。这应该可以解决问题:
soap().server(soapMtomServer)
.send()
.mtomEnabled(true)
.attachment("IMAGE", "application/octet-stream", new ClassPathResource("com/consol/citrus/hugeImageData.png"))
.payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService/\">" +
"<image>cid:IMAGE</image>" +
"</image:addImage>");
对于使用 Citrus Framework 的组件测试,我 模拟通过 SOAP[=29 调用的后端系统 =].
<citrus-ws:server id="backendSimulationServer"
port="8080"
auto-start="true"
interceptors="serverInterceptors"
timeout="5000"/>
我从组件获取 SOAP 请求并发回响应。
runner.receive(action -> action.endpoint("backendSimulationServer")
.name("search-request")
.payload(new ClassPathResource("testfiles/search-request-expectation.xml"))
);
runner.send(action -> action.endpoint("backendSimulationServer")
.name("search-response")
.payload(new ClassPathResource("testfiles/search-response.xml"))
);
但现在我必须用 MTOM 附件响应 来回答请求。我发现在 soap().client()
上使用 .attachment
的柑橘示例,但 .attachment
不适用于我的服务器模拟。
这可以用 Java DSL 实现吗?还是我要用 XML DSL 重写测试用例来实现这个?
SOAP 附件和启用 MTOM 的方法在 Citrus 的服务器组件上也可用。这应该可以解决问题:
soap().server(soapMtomServer)
.send()
.mtomEnabled(true)
.attachment("IMAGE", "application/octet-stream", new ClassPathResource("com/consol/citrus/hugeImageData.png"))
.payload("<image:addImage xmlns:image=\"http://www.citrusframework.org/imageService/\">" +
"<image>cid:IMAGE</image>" +
"</image:addImage>");