SOAP Client - Cannot use object of type stdClass as array
| From: | Dan Joseph | Date: | Thu, 19 Jun 2008 14:14:25 +0000 |
| Subject: | SOAP Client - Cannot use object of type stdClass as array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-275593@lists.php.net to get a copy of this message | ||
Hi,
I have a web service:
http://new.vehicletransportusa.com/v2/services/URS.QuoteServices.wsdl
I wrote a simple client to connect to it and get a quote, however I am
running into a snag. I get the below error when trying to run it. I've
tried it as an array, as an object, nothing seems to work. I have also
included the code. Any help would be appreciated.
*Fatal error*: Uncaught SoapFault exception: [SOAP-ENV:Server] Cannot use
object of type stdClass as array in
/home/yerkes/public_html/soap/client.php:119
Stack trace:
#0 [internal function]: SoapClient->__call('getQuote', Array)
#1 /home/yerkes/public_html/soap/client.php(119):
SoapClient->getQuote(Array)
#2 {main}
thrown in */home/yerkes/public_html/soap/client.php* on line *119*
<?php
$client = new SoapClient( "
http://new.vehicletransportusa.com/v2/services/URS.QuoteServices.wsdl"
);
$data = array ( "id" => 24,
"key" => "laksjdfl",
"firstname" => "Dan",
"lastname" => "Joseph",
"companyname" => "UR",
"dealername" => "",
"contact_address1" => "321 Street",
"contact_address2" => "",
"contact_city" => "Romulus",
"contact_state" => "MI",
"contact_zip" => "48167",
"emailaddress" => "djoseph@unitedroad.com",
"referral" => "24",
"origin_contactname" => "",
"origin_contactphone1" => "",
"origin_contactphone2" => "",
"origin_address1" => "",
"origin_address2" => "",
"origin_city" => "Northville",
"origin_state" => "MI",
"origin_zip" => "48167",
"dest_contactname" => "",
"dest_contactphone1" => "",
"dest_contactphone2" => "",
"dest_address1" => "",
"dest_address2" => "",
"dest_city" => "Beverly Hills",
"dest_state" => "CA",
"dest_zip" => "90210",
"phone" => "",
"cellphone" => "",
"fax" => "",
"contactpref" => "",
"vin" => "",
"color" => "",
"height" => "",
"buyer_id" => "",
"item_id" => "",
"engine_size" => "",
"modified" => "",
"pickupdate" => "",
"latestpickupdate" => "",
"make" => "Ford",
"model" => "Taurus",
"year" => "2002",
"vehicletype" => "1",
"inop" => "0",
"enclosed_carrier" => "0",
"quote_type" => "quote",
"savequote" => "1" );
try
{
$d = $client->getQuote( $data );
}
catch ( SoapException $e )
{
echo "<pre>";
print_r( $e );
echo "</pre>";
exit();
}
echo "<pre>";
var_dump( $d );
?>
--
-Dan Joseph
www.canishosting.com - Plans start @ $1.99/month.
"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."