【发布时间】:2011-11-28 06:55:20
【问题描述】:
我试图弄清楚如何编写 SOAP 请求的数组部分,其 WSDL 的相关部分如下:
<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>
使用soapUI,我可以看到SOAP 请求应该如下所示,除了我用“????”包裹的内容标签,soapUI 没有显示。 (另请注意,它将此节点显示为自闭合标记。)
<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>
我需要传入那个“ProductInfo”数组,但我不知道它的标签应该是什么样子。我试过这个没有用:
<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>
任何提示或类似示例的参考将不胜感激!
【问题讨论】:
-
我仍然可以使用帮助...仍然!
-
Dudeeee,请告诉我你知道怎么做吗?我需要帮助!
-
@E.E.33 我原以为 ProductInfo 上的 maxOccurs unbounded 可以解决问题,而不是尝试将其定义为数组