SOAP WSDL-如何在PHP中为特定方法创建工作调用

SOAP WSDL-如何在PHP中为特定方法创建工作调用,php,web-services,soap,wsdl,Php,Web Services,Soap,Wsdl,我在一个网站,将使用一些API的工作,并遇到了一个问题。 谁能帮帮我吗? 有一种叫做“createOrder”的方法,它让我很痛苦。 它用于在供应商处创建订单,如下所示: $id=$_POST['varname']; echo $id; $ilosc=$_POST['ilosc']; echo "</br> Zamawiana ilosć to :"; echo $ilosc; $orderInfo = $client->createOrder( array( '

我在一个网站,将使用一些API的工作,并遇到了一个问题。 谁能帮帮我吗? 有一种叫做“createOrder”的方法,它让我很痛苦。 它用于在供应商处创建订单,如下所示:

$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);
我还使用了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] =>
                                )
                        )

                )
        )
?>

如我所见,您的数据结构应该如下所示

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

   <?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] =>
                                )
                        )

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