Soap Client/Server “Invalid parameter (stdClass)”-Collection of common programming errors

Below I have included a stack trace of my PHP Client attempting to talk with the server. The client and server both read in the WSDL file file, so that part if of no concern.

As you can see by the second stack trace array item, I’m passing in a two dimensional array, but when the SoapServer does it’s __doRequest() function, the array has been concatenated into a single, unmanageable string. Any solution on how to fix this would be greatly appreciated.

Internal Server ErrorArray
(
[0] => Array
    (
        [function] => __doRequest
        [class] => SoapClient
        [type] => ->
        [args] => Array
            (
                [0] => 
1Colby Meiertruetrue5510.517.55601000250020100151502015302000true10false0true23true12false152002020023.51031000.345231003.25520152.45258.52011.255152012

                [1] => http://192.168.1.120/test_soap/Client_Billing.php
                [2] => 
                [3] => 1
                [4] => 0
            )

    )

[1] => Array
    (
        [file] => /var/www/test_soap/client_avid_new.php
        [line] => 92
        [function] => __call
        [class] => SoapClient
        [type] => ->
        [args] => Array
            (
                [0] => CreatePlan
                [1] => Array
                    (
                        [0] => Array
                            (
                                [session-id] => 1
                                [plan] => Array
                                    (
                                        [name] => Colby Meier
                                        [is-public] => 1
                                        [active] => 1
                                        [country-id] => 5
                                        [setup-fee] => 5
                                        [base-rate] => 10.5
                                        [quarterly-per-month-rate] => 17.5
                                        [bi-annual-per-month-rate] => 56
                                        [annual-per-month-rate] => 0
                                        [blast-limit] => 1000
                                        [social-limit] => 2500
                                        [keyword-limit] => 20
                                        [vote-limit] => 100
                                        [auto-response-limit] => 15
                                        [text-2-screen-limit] => 150
                                        [survey-limit] => 20
                                        [trivia-limit] => 15
                                        [text-2-win-limit] => 30
                                        [mobile-website-limit] => 2000
                                        [enable-ftp] => 1
                                        [ftp-fee] => 10
                                        [enable-contact-manager] => 
                                        [contact-manager-fee] => 0
                                        [enable-mobile-website] => 1
                                        [mobile-website-fee] => 23
                                        [enable-listrak] => 1
                                        [listrak-fee] => 12
                                        [enable-url-qr] => 
                                        [url-qr-fee] => 15
                                        [mt-quota] => 200
                                        [mt-overage] => 20
                                        [mo-quota] => 200
                                        [mo-overage] => 23.5
                                        [keyword-quota] => 10
                                        [keyword-overage] => 3
                                        [mobile-website-quota] => 100
                                        [mobile-website-overage] => 0.3
                                        [keyword-campaign-quota] => 45
                                        [keyword-campaign-overage] => 23
                                        [vote-quota] => 100
                                        [vote-overage] => 3.25
                                        [auto-response-quota] => 5
                                        [auto-response-overage] => 20
                                        [text-2-screen-quota] => 15
                                        [text-2-screen-overage] => 2.45
                                        [survey-quota] => 25
                                        [survey-overage] => 8.5
                                        [trivia-quota] => 20
                                        [trivia-overage] => 11.25
                                        [text-2-win-quota] => 5
                                        [text-2-win-overage] => 15
                                        [social-quota] => 20
                                        [social-overage] => 12
                                    )

                            )

                    )

            )

    )

[2] => Array
    (
        [file] => /var/www/test_soap/client_avid_new.php
        [line] => 92
        [function] => CreatePlan
        [class] => SoapClient
        [type] => ->
        [args] => Array
            (
                [0] => Array
                    (
                        [session-id] => 1
                        [plan] => Array
                            (
                                [name] => Colby Meier
                                [is-public] => 1
                                [active] => 1
                                [country-id] => 5
                                [setup-fee] => 5
                                [base-rate] => 10.5
                                [quarterly-per-month-rate] => 17.5
                                [bi-annual-per-month-rate] => 56
                                [annual-per-month-rate] => 0
                                [blast-limit] => 1000
                                [social-limit] => 2500
                                [keyword-limit] => 20
                                [vote-limit] => 100
                                [auto-response-limit] => 15
                                [text-2-screen-limit] => 150
                                [survey-limit] => 20
                                [trivia-limit] => 15
                                [text-2-win-limit] => 30
                                [mobile-website-limit] => 2000
                                [enable-ftp] => 1
                                [ftp-fee] => 10
                                [enable-contact-manager] => 
                                [contact-manager-fee] => 0
                                [enable-mobile-website] => 1
                                [mobile-website-fee] => 23
                                [enable-listrak] => 1
                                [listrak-fee] => 12
                                [enable-url-qr] => 
                                [url-qr-fee] => 15
                                [mt-quota] => 200
                                [mt-overage] => 20
                                [mo-quota] => 200
                                [mo-overage] => 23.5
                                [keyword-quota] => 10
                                [keyword-overage] => 3
                                [mobile-website-quota] => 100
                                [mobile-website-overage] => 0.3
                                [keyword-campaign-quota] => 45
                                [keyword-campaign-overage] => 23
                                [vote-quota] => 100
                                [vote-overage] => 3.25
                                [auto-response-quota] => 5
                                [auto-response-overage] => 20
                                [text-2-screen-quota] => 15
                                [text-2-screen-overage] => 2.45
                                [survey-quota] => 25
                                [survey-overage] => 8.5
                                [trivia-quota] => 20
                                [trivia-overage] => 11.25
                                [text-2-win-quota] => 5
                                [text-2-win-overage] => 15
                                [social-quota] => 20
                                [social-overage] => 12
                            )

                    )

            )

    )

)

Here is the code I call the client with:

$test = $client->CreatePlan(array("session-id"=>"1", "plan"=>$pa)); //$pa variable shown in stack trace

and here is the relevant code on the server:

 public function _checkArguments($arguments, $validParameters) {
    $variables = "";
    foreach ($arguments as $arg) {
        $type = gettype($arg);
        echo "type is ".$type;
        if ($type == "object") {
            $type = get_class($arg);
        }
        $variables .= "(".$type.")";
    }
    if (!in_array($variables, $validParameters)) {
        throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables));
    }
    return true;
}

/**
 * Service Call: CreatePlan
 * Parameter options:
 * (CreatePlan) parameters
 * @param mixed,... See function description for parameter options
 * @return CreatePlanResponse
 * @throws Exception invalid function signature messages
 */
public function CreatePlan($mixed = null) {
    $validParameters = array(
        "(CreatePlan)",
    );
    $args = func_get_args();
    echo "
Args are: ".print_r($args)."
";

    $this->_checkArguments($args, $validParameters);
    return $this->__soapCall("CreatePlan", $args);
}

As you'd expect, the function fails on the func_get_args(). This has been driving me completely nuts for the past couple days, so any advice would be greatly appreciated.

EDIT: When I say it fails on the func_get_args I mean that I get a null variable return. So in the case of $args = func_get_args(), $args is null.

EDIT 2: In case it helps get my issue solved, here’s the error from the Apache server’s logs.

[error] [client 192.168.1.120] PHP Fatal error: Uncaught exception 'Exception' with message 'Invalid parameter types: (stdClass)' in /var/www/test_soap/Client_Billing.php:2200\nStack trace:\n#0 /var/www/test_soap/Client_Billing.php(2220): Client_Billing->_checkArguments(Array, Array)\n#1 [internal function]: Client_Billing->CreatePlan(Object(stdClass))\n#2 /var/www/test_soap/Client_Billing.php(2642): SoapServer->handle()\n#3 {main}\n thrown in /var/www/test_soap/Client_Billing.php on line 2200

EDIT 3: As per request, here’s the WSDL snippet of the relevant types.



   
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
   
  

   
    
     
     
    
   
  

The Code to run the soap server:

$server = new SoapServer("http://192.168.1.120/Client_Billing.wsdl");
$server->setClass("Client_Billing");
$server->handle();