我正在使用cxf框架来处理soap消息。
身体看起来像:
<MyRequest> <Customers> <Customer>customer 1</Customer> <Customer>customer 2</Customer> <Customer>customer 3</Customer> </Customers> </MyRequest>
Using a LoggingInInterceptor I see a correct/complete request. However, I received only one element (customer 3) in the request object List.
Please help!
The xsd looks like..
<xsd:element name="MyRequest"> <xsd:complexType> <xsd:sequence minOccurs="1" maxOccurs="unbounded"> <xsd:element minOccurs="1" ref="Customers"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Customers" type="CustomersType"/> <xsd:complexType name="CustomersType"> <xsd:sequence> <xsd:element ref="ns2:name"/> </xsd:sequence> </xsd:complexType>
and the generation Request class:
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "customers" }) @XmlRootElement(name = "MyRequest") public class MyRequest { @XmlElement(name = "Customers", namespace = "http://schemas.kvk.nl/schemas/myCFXSoapService, required = true) protected List<Customer> customers; public List<CustomersType> getCustomers() { if (custmers == null) { customers = new ArrayList<CustomersType>(); } return this.customers; }
The xsd looks like..
<xsd:element name="MyRequest"> <xsd:complexType> <xsd:sequence minOccurs="1" maxOccurs="unbounded"> <xsd:element minOccurs="1" ref="Customers"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Customers" type="CustomersType"/> <xsd:complexType name="CustomersType"> <xsd:sequence> <xsd:element ref="ns2:name"/> </xsd:sequence> </xsd:complexType>
and the generation Request class:
@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "customers" }) @XmlRootElement(name = "MyRequest") public class MyRequest { @XmlElement(name = "Customers", namespace = "http://schemas.mycompany.com/schemas/myCFXSoapService, required = true) protected List<Customer> customers; public List<CustomersType> getCustomers() { if (custmers == null) { customers = new ArrayList<CustomersType>(); } return this.customers; }
And finally, the endpoint
public MyResponse process(final MyRequest request) { //some code to handle request }