我在这里阅读了一些其他解决方案,这些解决方案似乎与我遇到的问题相似,但似乎没有一个有效。无论如何,我需要调用一个soap函数,该函数具有一系列与其父元素同名的元素,并且这些名称都有一个“。” 在他们中。下面是 wsdl 的一部分,我似乎无法用一种方法来创建一个类似于所需的数组。
此外,'option.list' 的子数组总是会有不同的出现次数,所以我需要用 php 中的某种循环来构建它。任何帮助深表感谢。
<xs:element minOccurs="0" name="option.list">
<xs:complexType>
<xs:complexContent>
<xs:extension base="cmn:ArrayType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="option.list">
<xs:complexType>
<xs:complexContent>
<xs:extension base="cmn:StructureType">
<xs:sequence>
<xs:element minOccurs="0" name="SubItemId" nillable="true" type="cmn:DecimalType"/>
<xs:element minOccurs="0" name="SubOptions" nillable="true" type="cmn:StringType"/>
<xs:element minOccurs="0" name="SubItemName" nillable="true" type="cmn:StringType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
我尝试过的想法:
for($i=0;$i<count($options);$i++)
{
$option_list[] = array(
"option.list" => array(
"SubItemId" => $i,
"SubOptions" => $options[$i]['suboptions'],
"SubItemName" => $options[$i]['subitemname']
)
);
}
$instance = array(
"option.list"=>$option_list
);
当我调试请求时,它一直显示这是我发送的内容:
<ns1:option.list><ns1:option.list/></ns1:option.list>
此外,这就是我在发送之前 print_r 时 option.list 数组的样子,如果这有帮助的话。
[option.list] => Array
(
[0] => stdClass Object
(
[option.list] => stdClass Object
(
[SubItemId] => 0
[SubOptions] => <?xml version="1.0" encoding="UTF-8" standalone="yes"?><form><select id="DBMS" label="DBMS type:" style="combo">MS SQL<option label="" /><option id="0" label="DB2">DB2</option><option id="1" label="IMS">IMS</option><option id="2" label="MS SQL">MS SQL</option><option id="3" label="Oracle">Oracle</option><option id="4" label="UDB">UDB</option></select><select id="Type" label="lation Type:" style="combo">Add New Instance<option label="" /><option id="0" label="Add New Environment">Add New Environment</option><option id="1" label="Add New Instance">Add New Instance</option><option id="2" label="Add New Database">Add New Database</option><option id="3" label="Modify Environment">Modify Environment</option><option id="4" label="Modify Instance">Modify Instance</option><option id="5" label="Modify Database">Modify Database</option><option id="6" label="Retire Environment">Retire Environment</option><option id="7" label="Retire Instance">Retire Instance</option><option id="8" label="Retire Database">Retire Database</option></select><select id="Complexity" label="xity:" style="combo">Complex [+$2500.00]<option label="" /><option id="0" label="Simple [+$500.00]">Simple [+$500.00]</option><option id="1" label="Medium [+$1000.00]">Medium [+$1000.00]</option><option id="2" label="Complex [+$2500.00]">Complex [+$2500.00]</option></select><select id="RecoveryTier" label="rability Tier:" style="combo">Tier 2<option label="" /><option id="0" label="Tier 1">Tier 1</option><option id="1" label="Tier 2">Tier 2</option><option id="2" label="Tier 3">Tier 3</option></select><select id="Backup" label=" Backup Required?" style="combo">Yes<option label="" /><option id="0" label="Yes">Yes</option><option id="1" label="No">No</option></select><select id="Replication" label=" tables require replication?" style="combo">UDB Dprop<option label="" /><option id="0" label="UDB Dprop">UDB Dprop</option><option id="1" label="Goldengate">Goldengate</option><option id="2" label="ASM">ASM</option><option id="3" label="No">No</option></select></form>
[SubItemName] => DB Modification
)
)
)