Search code examples
phpsoapnusoap

SOAP request with 500 error


I'm using the NuSOAP and i'm trying to make a request but always getting the 500 error:

<?php
require_once('../lib/nusoap.php');

$c = new soapclient('http://example.com/index.asmx?WSDL');

$clientVAT = $c->call('GetClient',
              array(
                'empresa' => '*****',
                'password' => '******',
                'nif' => '*******',
                ));

echo "clientVAT $clientVAT.";

?> 

Shouldn't this be enough to get a response from the server?


Solution

  • In your wsdl, you have a complexType with 2 levels

    <s:element name="GetClientesNif">
        <s:complexType>
            <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="empresa" type="s:string"/>
                <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
                <s:element minOccurs="0" maxOccurs="1" name="nif" type="s:string"/>
            </s:sequence>
        </s:complexType>
    </s:element>
    

    That's why you need to send a request with a 2 levels array :

    Try with this :

    $myArray[] = array(
                    'empresa' => '*****',
                    'password' => '******',
                    'nif' => '*******',
                    );
    
    $clientVAT = $c->call('GetClientesNif', $myArray);