java - Spring Boot 在 SOAP 集成测试请求中添加信封
问题描述
我正在尝试进行 SOAP 集成测试。我有一个 XML 文件作为请求,在 SOAPUI 中它有一个肥皂信封页眉和页脚,如下所示:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.billing.nulogix.com">
<soapenv:Header/>
<soapenv:Body>
<ser:analyze>
<ser:studyContainer>
<![CDATA[
和
]]>
</ser:studyContainer>
<ser:studyContainerVersion>3.17.6.12</ser:studyContainerVersion>
</ser:analyze>
</soapenv:Body>
</soapenv:Envelope>
我需要将其包含在集成测试中。到目前为止,我这样做了:
private String studyDetailDemo;
private String header = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://service.billing.nulogix.com\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <ser:analyze>\n" +
" <ser:studyContainer>\n" +
"<![CDATA[\n";
private String footer = "]]>\n" +
" </ser:studyContainer>\n" +
" <ser:studyContainerVersion>3.17.6.12</ser:studyContainerVersion>\n" +
" </ser:analyze>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
private String request = header + studyDetailDemo + footer;
@Test
public void soapTest() throws ClientProtocolException, IOException {
String result = Request.Post("https://127.0.0.1:28443/nulogix/ws/billingtool")
.connectTimeout(2000)
.socketTimeout(2000)
.bodyString(request, ContentType.TEXT_XML)
.execute().returnContent().asString();
当我在 mvn 中运行它时,我得到了这个错误:
StudyDetails unmarshal failed due to JAXBException javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.]
解决方案
推荐阅读
- c++ - C++ socket.io 客户端通过 Tor 服务
- python - Plotly:重新标记滑块上的动画刻度线
- c# - 具有继承类的实体框架核心模型生成器
- cassandra - Cassandra 是否会丢弃失败的写入记录或在读取修复期间传播它?
- android - 在 Android 上使用 Viewpager2 的底页
- ruby-on-rails - 加载rails控制台时如何修复'mysql2'错误?
- python - 如何将 API 调用中的数据打印到 CSV 文件中
- mysql - 如何在 MySQL 查询中找到最大总和的关联名称?
- html - 通过 image-weblink 下载图片
- swift - MFMailComposeViewController 不显示取消按钮