2017-07-07 5 views
0

私はいくつかのAPIを使用し、問題が発生したWebサイトで作業しています。 誰かが私を助けてくれますか? "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); 

問題は、それが「位置」を通過させないということです。空白の順序を作成するだけです(この4つの最初のパラメーターを使用)。問題は私の意見では、これらの「位置」ブロックは複数のアイテムを扱うように設計されているため、別の方法で記述する必要があります。

ここにいくつかのヘルプの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] => 
           ) 
         ) 

       ) 
     ) 
?> 

あなたが仕事をachiveために私を助けてもらえソリューション? ありがとうございます。

答えて

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

はそれが

を役に立てば幸いとして、あなたのデータ構造は次のようにする必要があります
関連する問題