我尝试将Soap Web Service从Axis1迁移到Spring Boot,但是我无法绑定包含“ multiref”标签的请求。 有人可以告诉我如何解决吗? ,谢谢
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<ns1:holidayService soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://service.inbound">
<requestMessage href="#id0"/>
</ns1:holidayService>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:RequestMessage" xmlns:ns2="http://service.inbound" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<operation xsi:type="xsd:string">INQUIRY</operation>
<requestData href="#id1"/>
</multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:RequestData" xmlns:ns3="http://service.inbound" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<bankCode xsi:type="xsd:string">R01</bankCode>
<initialYear href="#id2"/>
<sponsorCode xsi:type="xsd:string">TE001</sponsorCode>
</multiRef>
<multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">2019</multiRef>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:0)
我发现了带有Interceptor“ TransformerObjectSupport”的解决方案,这是我的解决方案
1添加xsl样式表文件以进行转换
public class OrderNotify {
public String orderid;
public String date;
public String status;
public String handle;
public OrderNotify(String orderid, String date, String status, String handle) {
this.orderid = orderid;
this.date = date;
this.status = status;
this.handle = handle;
}
public List<String> getAll(){
return null;
}
public String getOrderid() {
return orderid;
}
public void setOrderid(String orderid) {
this.orderid = orderid;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getHandle() {
return handle;
}
public void setHandle(String handle) {
this.handle = handle;
}
}
2添加用于转换有效载荷的拦截器
<tr th:each="notify : [com.example.spring.utils.OrderNotify@42b3c931, com.example.spring.utils.OrderNotify@76af8a32, com.example.spring.utils.OrderNotify@28025a03, com.example.spring.utils.OrderNotify@5e6eadf0, com.example.spring.utils.OrderNotify@2481d4d, com.example.spring.utils.OrderNotify@83ce92c, com.example.spring.utils.OrderNotify@3254786a, com.example.spring.utils.OrderNotify@197e42fd, com.example.spring.utils.OrderNotify@5b1e86ea, com.example.spring.utils.OrderNotify@3484712c]">
<td th:text=""></td>
<td th:text=""></td>
<td th:text=""></td>
<td th:text=""> </td>
</tr>
3。在配置类中添加这样的拦截器
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" >
<xsl:key name="multiref-by-id" match="multiRef" use="@id"/>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@*|*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[starts-with(@href, '#')]">
<xsl:copy>
<xsl:apply-templates select="@* |
key('multiref-by-id', substring-after(@href, '#'))/@* |
key('multiref-by-id', substring-after(@href, '#'))/node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@href[starts-with(., '#')] | multiRef[@id] | @soapenc:root"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
}