'Complex Array in SOAP Request
I'm trying to figure out how to write the array part of a SOAP request whose relevant part of its WSDL is this:
<xsd:complexType name="ArrayOfProductInfo">
<xsd:complexContent>
<xsd:restriction base="soap-enc:Array">
<xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:ProductInfo[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ProductInfo">
<xsd:all>
<xsd:element name="productID" type="xsd:string"/>
<xsd:element name="quantity" type="xsd:int"/>
<xsd:element name="price" type="xsd:float"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="clCostRequest">
<xsd:all>
<xsd:element name="language" type="xsd:string"/>
<xsd:element name="items" type="tns:ArrayOfProductInfo"/>
<xsd:element name="shipmentOriginCountry" type="xsd:string"/>
<xsd:element name="shipmentDestinationCountry" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
With soapUI, I'm able to see that the SOAP request should look as follows, except for what I've wrapped in "????" tags, which soapUI is not displaying. (Note also that it's displaying this node as a self-closing tag.)
<soapenv:Envelope mlns:xsi="http:...">
<soapenv:Header/>
<soapenv:Body>
<clCost soapenv:encodingStyle="http://schemas.xmlsoap.org/...">
<request xsi:type="clCostRequest">
<language xsi:type="xsd:string">en</language>
<items xsi:type="ArrayOfProductInfo" soapenc:arrayType="ProductInfo[]"/>
<????>productID</????>
<????>quantity</????>
<????>price</????>
<????>productID</????>
<????>quantity</????>
<????>price</????>
<shipmentOriginCountry xsi:type="xsd:string">US</shipmentOriginCountry>
<shipmentDestinationCountry xsi:type="xsd:string">DE</shipmentDestinationCountry>
</request>
</clCost>
</soapenv:Body>
</soapenv:Envelope>
I need to pass in that "ProductInfo" array but I don't know what its tags should look like. I've tried this to no avail:
<items xsi:type="ArrayOfProductInfo" soapenc:arrayType="ProductInfo[]">
<ProductInfo xsi:type="tns:ProductInfo">
<productID xsi:type="xsd:string">86595</productID>
<quantity xsi:type="xsd:int">50</quantity>
<price xsi:type="xsd:float">1.99</price>
</ProductInfo>
<ProductInfo xsi:type="tns:ProductInfo">
<productID xsi:type="xsd:string">12215</productID>
<quantity xsi:type="xsd:int">60</quantity>
<price xsi:type="xsd:float">5.99</price>
</ProductInfo>
</items>
Any hints or references to similar examples would be greatly appreciated!
Solution 1:[1]
SoapUI will translate the WSDL you give him and display you the requests and their parameters. Whatever SOAPUI generated from WSDL should be correct. Therefore I advise you to check your WSDL, because the fault is there.
Solution 2:[2]
This should Work
<soapenv:Envelope mlns:xsi="http:...">
<soapenv:Header/>
<soapenv:Body>
<clCost soapenv:encodingStyle="http://schemas.xmlsoap.org/...">
<request xsi:type="clCostRequest">
<language xsi:type="xsd:string">en</language>
<items xsi:type="ArrayOfProductInfo" soapenc:arrayType="ProductInfo[]">
<item xsi:type="xsd:ProductInfo">
<productID xsi:type="xsd:string">86595</productID>
<quantity xsi:type="xsd:int">50</quantity>
<price xsi:type="xsd:float">1.99</price>
</item>
<item xsi:type="xsd:ProductInfo">
<productID xsi:type="xsd:string">12215</productID>
<quantity xsi:type="xsd:int">60</quantity>
<price xsi:type="xsd:float">5.99</price>
</item>
</items>
<shipmentOriginCountry xsi:type="xsd:string">US</shipmentOriginCountry>
<shipmentDestinationCountry xsi:type="xsd:string">DE</shipmentDestinationCountry>
</request>
</clCost>
</soapenv:Body>
</soapenv:Envelope>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bart |
| Solution 2 | Vial |
