首页 > 解决方案 > SOAP XML 有效 xsi:type

问题描述

我正在尝试编写一个 SOAP 调用,示例请求如下:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://server.opsware.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:attachPolicies soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <self xsi:type="xsd:anyType">?</self>
         <policies xsi:type="ser:ArrayOf_xsd_anyType" soapenc:arrayType="xsd:anyType[]"/>
      </ser:attachPolicies>
   </soapenv:Body>
</soapenv:Envelope>

ArrayOf_xsd_anyType关于可能意味着什么或我如何找到有效选项的任何想法?

标签: xmlsoaphpsa

解决方案


只是为了澄清您的术语,您展示的不是 WSDL,而是 SOAP 服务的示例 SOAP 请求。WSDL 是一个 XML 文档,描述了请求和响应中使用的 XML 类型,以及 PortType、Binding 和 Service 信息。

至于anyType,此链接提供了其用法的清晰概述: https ://www.ibm.com/support/knowledgecenter/SSFTDH_8.0.0/com.ibm.wbpm.main.doc/topics/cbo_usinganytype.html

但是 TL;DR 是这样的:“anyType 允许任何 DataObject 而不管类型如何。如果 maxOccurs > 1,则列表中的每个 DataObject 都可以[是]不同的类型。”

这与仅限于单一类型的“complexType”形成对比。例如,如果您有一个complexType数据数组,则所有数组值必须属于同一类型(“客户”、“地址”等)。


推荐阅读