Ответ SOAP с массивом, не приведенным к типизированному объекту (get elementNSImpl)Как это решить?

#xml #spring-boot #soap #wsdl #soap-client

Вопрос:

У меня проблема с приведением ответа soap для определения типа(класса).

Все работает с другими моделями, но в этом вызове soap я получаю ответ, содержащий массив объектов(invoice_details), и в этом вызове я получаю elementNSimpl.

Вот ответ пользовательского интерфейса SOAP:

 <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.sugarcrm.com/sugarcrm">
   <SOAP-ENV:Body>
      <ns1:get_invoice_listResponse xmlns:ns1="http://www.sugarcrm.com/sugarcrm">
         <return xsi:type="tns:invoice_list_cus_info">
            <customer_info xsi:type="tns:customer_info">
               <customer_name xsi:type="xsd:string">Тест Тест</customer_name>
            </customer_info>
            <invoice_list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:invoice_details[1]">
               <item xsi:type="tns:invoice_details">
                  <month xsi:type="xsd:string">xxxxxxxxxxxx</month>
                  <invoice_number xsi:type="xsd:string">xxxxxxxxxxxxxx</invoice_number>
                  <amount xsi:type="xsd:string">xxxxxxxxxxxxxxxx</amount>
               </item>
            </invoice_list>
            <status_message xsi:type="xsd:string">Success</status_message>
         </return>
      </ns1:get_invoice_listResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 

Этот класс создается с помощью плагина maven-jaxb2.

Вот сгенерированные классы:

 @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
        "_return"
})
@XmlRootElement(name = "get_invoice_listResponse")
public class GetInvoiceListResponse {

    @XmlElement(name = "return", required = true, nillable = true)
    protected InvoiceListCusInfo _return;

    /**
     * Gets the value of the return property.
     *
     * @return possible object is
     * {@link InvoiceListCusInfo }
     */
    public InvoiceListCusInfo getReturn() {
        return _return;
    }

    /**
     * Sets the value of the return property.
     *
     * @param value allowed object is
     *              {@link InvoiceListCusInfo }
     */
    public void setReturn(InvoiceListCusInfo value) {
        this._return = value;
    }

}
 

Это InvoiceListCusInfo.class

 @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "invoice_list_cus_info", propOrder = {

})
public class InvoiceListCusInfo {

    @XmlElement(name = "customer_info", required = true)
    protected CustomerInfo customerInfo;
    @XmlElement(name = "invoice_list", required = true)
    protected InvoiceList invoiceList;
    @XmlElement(name = "total_amount", required = true)
    protected java.lang.String totalAmount;
    @XmlElement(name = "status_message", required = true)
    protected java.lang.String statusMessage;

    getter/setter

}
 

This is InvoiceList.class

 @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "invoice_list")
public class InvoiceList
    extends Array
{


}
 

This is Array.class

 @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Array", namespace = "http://schemas.xmlsoap.org/soap/encoding/", propOrder = {
    "any"
})
@XmlSeeAlso({
    InvoiceList.class
})
public class Array {

    @XmlAnyElement(lax = true)
    protected List<Object> any;
    @XmlAttribute(name = "arrayType", namespace = "http://schemas.xmlsoap.org/soap/encoding/")
    protected java.lang.String arrayType;
    @XmlAttribute(name = "offset", namespace = "http://schemas.xmlsoap.org/soap/encoding/")
    protected java.lang.String offset;
    @XmlAttribute(name = "id")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    @XmlSchemaType(name = "ID")
    protected java.lang.String id;
    @XmlAttribute(name = "href")
    @XmlSchemaType(name = "anyURI")
    protected java.lang.String href;
    @XmlAnyAttribute
    private Map<QName, java.lang.String> otherAttributes = new HashMap<QName, java.lang.String>();
 

I get this response:

     {
        "customerInfo": {
            "customerName": "xxxxxxxxxxx",
            "address": null
        },
        "invoiceList": {
            "any": [
                "<?xml version="1.0" encoding="UTF-16"?>n<item xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.sugarcrm.com/sugarcrm" xmlns:tns="http://www.sugarcrm.com/sugarcrm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="tns:invoice_details">
<month xsi:type="xsd:string">xxxxxxx5</month>
<invoice_number xsi:type="xsd:string">xxxxxxxx</invoice_number>
<amount xsi:type="xsd:string">xxxxxxxx</amount></item>"
            ],
            "arrayType": "tns:invoice_details[1]",
            "offset": null,
            "id": null,
            "href": null,
            "otherAttributes": {}
        },
        "totalAmount": null,
        "statusMessage": "Success"
    }
 

How to cast this array to array of invoice_details?

Thanks for all your help.