note 112757 added to soapvar.soapvar
| From: | it at teamamericany dot com | Date: | Fri, 19 Jul 2013 21:13:37 +0000 |
| Subject: | note 112757 added to soapvar.soapvar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195682@lists.php.net to get a copy of this message | ||
To send requests containing ComplexTypes we needed to create stdClass objects for each ComplexType.
If the ComplexType has an attribute we created a class with all the fields and attributes as members
and added this class to the classmap with the correct type name from the wsdl. For example:
//to create soap client
$soapClient = new SoapClient("<your wsdl url>",
array('classmap' => array('RoomType' => 'RoomType'),
'trace' => 1));
//creating request object using custom class since there is an attribute needed
class RoomType {
//attribute
var $code;
var $name;
}
$RoomType = new RoomType();
$RoomType->code = $code;
//plain stdClass is ok since no attributes defined
$LRoomCode = new stdClass();
$LRoomCode->RoomType = new SoapVar($RoomType, SOAP_ENC_OBJECT, "RoomType",
"<your namespace url from wsdl>");
//define a basic class object since attributes are not needed for this complex type
$RateAvailabilityReq = new stdClass();
$RateAvailabilityReq->LRoomCode = new SoapVar($LRoomCode, SOAP_ENC_OBJECT,
"ArrayOfRoomType", "<your namespace url>");
$RateAvailabilityReq->idB2BHotel = $idB2BHotel;
$RateAvailabilityReq->idProduct = $idProduct;
$RateAvailabilityReq->lenght = $lenght;
$RateAvailabilityReq->nameDistributor = $nameDistributor;
$RateAvailabilityReq->password = $password;
$RateAvailabilityReq->propertyCode = $propertyCode;
$RateAvailabilityReq->startDate = $startDate;
$RateAvailabilityReq->userName = $userName;
$RateUpdateReqType = new SoapVar($RateAvailabilityReq , SOAP_ENC_OBJECT,
"RateAvailabilityReq", "<your namespace url>");
$soapRequestType = new stdClass();
$soapRequestType->in0 = $RateUpdateReqType;
$getRateAvailabilityReq = new SoapVar($soapRequestType , SOAP_ENC_OBJECT,
"getRateAvailability", "<your namespace url>");
$result = $soapClient->getRateAvailability($getRateAvailabilityReq);
Reading attributes from ComplexType response objects also required a custom class added to the
classmap array with the attribute as a member of the class.
----
Server IP: 69.147.83.199
Probable Submitter: 64.244.218.35
----
Manual Page -- http://php.net/manual/en/soapvar.soapvar.php
Edit -- https://master.php.net/note/edit/112757
Del: integrated -- https://master.php.net/note/delete/112757/integrated
Del: useless -- https://master.php.net/note/delete/112757/useless
Del: bad code -- https://master.php.net/note/delete/112757/bad+code
Del: spam -- https://master.php.net/note/delete/112757/spam
Del: non-english -- https://master.php.net/note/delete/112757/non-english
Del: in docs -- https://master.php.net/note/delete/112757/in+docs
Del: other reasons-- https://master.php.net/note/delete/112757
Reject -- https://master.php.net/note/reject/112757
Search -- https://master.php.net/manage/user-notes.php