【发布时间】:2018-06-25 09:48:57
【问题描述】:
我已经构建了一个示例 Citrus 测试用例来模拟一个响应 MTOM 附件的 SOAP 服务器。
runner.soap(action -> action.server("simulationServer")
.receive()
...[validation etc]
);
runner.soap(action -> action.server("simulationServer")
.send()
.name("get-response")
.mtomEnabled(Boolean.TRUE)
.attachment("myAttachment", "application/octet-stream", new ClassPathResource("testfiles/myAttachment.pdf"))
.payload("<getResponse xmlns:xmime=\"http://www.w3.org/2005/05/xmlmime\">\n" +
" <document>\n" +
" <contentElements>\n" +
" <contentElement xmime:contentType=\"application/pdf\">cid:myAttachment</contentElement>\n" +
" </contentElements>\n" +
" <id>Test</id>\n" +
" </document>\n" +
"</getResponse>\n")
);
当我运行此测试并使用 SoapUI 调用 Citrus 模拟时,我在调试日志中看到了 myAttachment.pdf 的内容。所以至少看起来 Citrus 试图发送附件。
但是,在 SoapUI 中我没有收到附件。 SOAP 响应中有一个 XOP 元素,但没有附件。 Citrus 响应的 SoapUI 的 RAW 视图如下所示。
HTTP/1.1 200 OK
Date: Tue, 16 Jan 2018 15:30:36 GMT
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
SOAPAction: ""
Content-Type: Multipart/Related; boundary="----=_Part_0_382348859.1516116636524"; type="application/xop+xml"; start-info="text/xml"
Transfer-Encoding: chunked
Server: Jetty(9.4.6.v20170531)
------=_Part_0_382348859.1516116636524
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><getResponse xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
<document>
<contentElements>
<contentElement xmime:contentType="application/pdf"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:myAttachment"/></contentElement>
</contentElements>
<id>Test</id>
</document>
</getResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
------=_Part_0_382348859.1516116636524--
在带有附件的 MTOM 响应中,附件从 RAW 视图结束处开始。应该这样继续下去
------=_Part_0_382348859.1516116636524-- [last line from above]
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <myAttachment>
%PDF-1.4... [PDF content]
我正在使用 Citrus 2.7.2 版本。
更新
在这方面仍然没有成功。 Wireshark 显示与 SoapUI 相同的图片:响应中缺少附件。
但是,当我在服务器(Citrus)端调试代码时,我会在响应消息中看到附件,直到我在 MessageSendingTemplate 的某个地方迷路。在控制台日志上也是如此。邮件有附件。
Citrus 文档中有一个内联 MTOM 变体,但我找不到在 Java 配置中的附件上设置此 mtom-inline 的方法。
任何提示,在哪里设置断点以查找附件丢失的位置?或者柑橘方面的任何其他建议/例子?
【问题讨论】:
标签: soap mtom citrus-framework