2013-04-29 108 views
1

我通過其他一些解決方案閱讀了這裏的幾個問題,看起來類似於我遇到的問題,但似乎沒有任何工作。無論如何,我需要調用一個具有與它們的父元素相同名稱的元素序列的soap函數,並且這些名稱都具有'。'。在他們中。下面是wsdl的一部分,我似乎無法用創建一個類似於需要的數組的方式來包裝我的頭。PHP soapClient和序列問題

此外,'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> 

此外,這是什麼在我發送之前,option.list數組看起來像我print_r,如果這有幫助的話。

   [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 
            ) 

          ) 

        ) 
+0

這裏是我試過的最後一件事片段....不能在此評論添加它..現在編輯我原來的帖子。 – Mike 2013-04-29 22:37:41

+0

_it不斷顯示這是我發送的 - 是你發送你打算髮送什麼?你會包含調用SoapClient的代碼嗎? – halfer 2013-04-30 21:10:24

+0

這不是我所期望的,它應該發送的是 0轉義xml here DB Modification Mike 2013-04-30 21:35:05

回答

2

我從來沒有真正能夠弄清楚如何從對象或數組中獲得所需的soapEnvelope。但作爲一種功能性解決方法,我能夠繼承SoapClient並覆蓋__doRequest方法。這使我發送我自己的原始XML請求,現在正在工作。

我發現這個解決辦法在這裏:Sending Raw XML via PHP SoapClient request

0

我建議下面的代碼,但我沒有嘗試:

for($i=0;$i<count($options);$i++) { 
    $option_list[] = array(
     "SubItemId" => $i, 
     "SubOptions" => $options[$i]['suboptions'], 
     "SubItemName" => $options[$i]['subitemname'] 
    ) 
} 

$instance = array(
    "option.list"=>$option_list 
); 

我想你需要不使具有鑰匙'父陣列option.list」。 名稱'option.list'僅用於wsdl類型引用本身,但根本不發送。 的WSDL只是告訴你:「option.list」類型是一個關聯數組的基本陣列:

array(
    array(
     'SubItemId' => <DECIMAL>, 
     'SubOptions' => '<STRING>', 
     'SubItemName' => '<STRING>' 
    ), 
    array(
     'SubItemId' => <DECIMAL>, 
     'SubOptions' => '<STRING>', 
     'SubItemName' => '<STRING>' 
    ), 
    array(
     'SubItemId' => <DECIMAL>, 
     'SubOptions' => '<STRING>', 
     'SubItemName' => '<STRING>' 
    ), 
    ..., 
    ... 
)