2017-07-07 59 views
0

我正在使用一些API並且遇到問題的網站上工作。 有人可以幫我嗎? 有這種方法稱爲「createOrder」,這是殺了我。 它用於在供應商創造秩序,如下所示:SOAP WSDL - 如何創建PHP中特定方法的工作調用

$id=$_POST['varname']; 
echo $id; 
$ilosc=$_POST['ilosc']; 
echo "</br> Zamawiana ilosć to :"; 
echo $ilosc; 
$orderInfo = $client->createOrder( 
array( 

    'description'=> 'OPIS', 
    'clientNr' => '025537', 
    'type' => 'FV_ZBIORCZA', 
    'transport' =>'AD', 
    'positions' => array(


    'id'=>$id, 
    'count'=>$ilosc 

    ) 

)) ; 

var_dump($orderInfo); 

的問題是,它不通過「位置」。它僅創建一個空白訂單(使用這四個第一個參數)。問題是在我看來,這些「職位」塊旨在處理多個項目,所以它必須以不同的方式寫入。

這裏是SOAP UI代碼的一些幫助。它的工作原理,只有「ID」,並填寫「計數」(和api_keys以及課程):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://katalog.adpolska.pl/ws/api/1.0/"> 
    <soapenv:Header> 
     <personal_key>?</personal_key> 
     <kh_kod>?</kh_kod> 
     <api_key>?</api_key> 
    </soapenv:Header> 
    <soapenv:Body> 
     <ns:createOrder> 
     <order> 
      <!--You may enter the following 5 items in any order--> 
      <description>OPIS</description> 
      <clientNr>025537</clientNr> 
      <type>FV_ZBIORCZA</type> 
      <transport>AD</transport> 
      <positions> 
       <!--Zero or more repetitions:--> 
       <item> 
        <!--You may enter the following 4 items in any order--> 
        <productId> 
        <!--You may enter the following 2 items in any order--> 
        <id>824210</id> 
        <index></index> 
        </productId> 
        <count>2</count> 
        <error></error> 
        <errorMessage></errorMessage> 
       </item> 
      </positions> 
     </order> 
     </ns:createOrder> 
    </soapenv:Body> 
</soapenv:Envelope> 

下面的例子中,從文件,但這個文件有這麼多的錯誤,我不再看它,它也心不是工作,而是給出了思路:

$orderInfo = $client->__soapCall('createOrder', [ 
     'order' => [ 
       'description' =>'myDesc', 
       'clientNr' =>'my_cart_nr', 
       'type' =>'FV', 
       'transport' =>'AD', 
       'positions' => [ 
         [ 
           'id' =>'907972', 
           'count' => 1 
         ], 
         [ 
           'id' =>'908015', 
           'count' => 1 
         ] 
       ] 
     ] 
]); 

我也用這個功能類似wsdltophp,並提取結構:

<?php 

Array 
(
    [0] => ADStructOrder Object 
     (
      [description] => OPIS 
      [clientNr] => 025537 
      [type] => FV_ZBIORCZA 
      [transport] => AD 
      [positions] => ADStructArrayOfOrderPosition Object 
       (
        [item] => Array 
         (
          [0] => ADStructOrderPosition Object 
           (
            [productId] => ADStructProductId Object 
             (
              [id] => 823514 
              [index] => 
             ) 
            [count] => 1 
            [error] => 
            [errorMessage] => 
           ) 
         ) 

       ) 
     ) 
?> 

能否請你幫我才達到工作解決方案? 在此先感謝。

回答

0

依我之見,你的數據結構應該像爲

<?php 
$productId = [ 
    'id' => 824210, 
    'index' => '' 
]; 
$item = [ 
    'productId' => $productId, 
    'count' => 2, 
    'error' => '', 
    'errorMessage' => '' 
]; 
$positions = [ 
    'item' => [$item], 
]; 
$order = [ 
    'description'=> 'OPIS', 
    'clientNr' => '025537', 
    'type' => 'FV_ZBIORCZA', 
    'transport' =>'AD', 
    'positions' => $positions, 
]; 

$orderInfo = $client->createOrder($order); 

希望它有助於