Search code examples
phpsoapwsdlsoapui

Pass array of objects as param to SOAP function and php-wsdl


i'm trying to setup a SOAP server with a function that reads an array of objects as parameter. I'm generating WSDL with php-wsdl. Here's my approach:

/**
 * TStanMag
 * 
 *
 * @pw_set nillable=false The next element can't be NULL
 * @pw_element string $kodTowaru Kod towaru
 * @pw_set nillable=false The next element can't be NULL
 * @pw_element float $ilosc Dostępna ilość
 * @pw_complex TStanMag Pozycja stanu magazynowego
 */
class TStanMag {
    public $kodTowaru;
    public $ilosc;
};

...

/**
 * Aktualizacja stanów magazynowych
 * 
 * @param string $key1 Klucz 1
 * @param string $key2 Klucz 2
 * @param TStanMag[] $stany Tabela stanów magazynowych
 * @param int $store_id
 * @return TResult[] Response
 */
public function AktualizujStanyMagazynowe($key1, $key2, $stany, $store_id = 0) {
...
}

but in WSDL i see this type instead of array of types:

<wsdl:part name="stany" type="tns:TStanMag[]">
<s:documentation>Tabela stanów magazynowych</s:documentation>
</wsdl:part>

also getting warning in SoapUI

Thu Mar 19 21:04:38 CET 2015:WARN:Failed to find type [{http://localhost/symsync/}TStanMag[]]

How can I fix this?


Solution

  • In the meantime I solved this. Working code below.

    /**
     * TStanMag
     * 
     *
     * @pw_set nillable=false The next element can't be NULL
     * @pw_element string $kodTowaru Kod towaru
     * @pw_set nillable=false The next element can't be NULL
     * @pw_element float $ilosc Dostępna ilość
     * @pw_complex TStanMag Pozycja stanu magazynowego
     */
    class TStanMag {
        public $kodTowaru;
        public $ilosc;
    };
    
    /**
     * TStanMagArray
     * 
     *
     * @pw_element TStanMag $TStanMag Kod towaru
     * @pw_complex TStanMagArray Tablica pozycji stanu magazynowego
     */
    class TStanMagArray {
        public $TStanMag;
    };
    

    ...

    /**
         * Aktualizacja stanów magazynowych
         * 
         * @param string $key1 Klucz 1
         * @param string $key2 Klucz 2
         * @param TStanMagArray $stany Tabela stanów magazynowych
         * @param int $store_id
         * @return TResultArray Response
         */
        public function AktualizujStanyMagazynowe($key1, $key2, $stany, $store_id = 0) {