Hi Guys!
First post but I lost my details of my old account Might as well say a new hello!
Hit a bit of a problem and ive been stuck at this stage for ages now. My head has turned into mush!
Im fumbling around using the new SOAP features of PHP5 for the first time. Its all new to me. Ive been getting along nicely but Im hitting brick walls quite often in the formatting of my requests to a webservice. Ive got access to a test system for hotel bookings for practice with the documentation etc and its pretty nifty when I can get it to work.
At present I am just looking to hard code a request and then build in the dynamic details from a form.
$xmlHotels = $client->FindAvailableHotels(
array(
'SessionId' => $_SESSION['booking_session_id'],
'Operators' => array('OperatorCode' => 'XXXXXX'),
'StayDateRange' => array(
'Start' => $_GET['year'] . '-' . $_GET['month'] . '-' . $_GET['date'],
'End' => $_GET['year'] . '-' . $_GET['month'] . '-' . ($_GET['date']+$_GET['duration'])
),
'RoomStayCandidate' => array(
'GuestCounts' => array(
'PerRoom' => array(
'PerRoomRecordNumber' => '1',
'Adults' => array(
array('Person' => ''),
array('Person' => '')
),
'Children' => array(
array('Person' => array('Age' => array('Value' => 8))),
array('Person' => array('Age' => array('Value' => 10)))
),
'Infants' => array(
array('Person' => '')
)
)
)
),
'HotelSearchCriterion' => array(
'Locations' => array(
'Location' => array(
'AirportCode' => $_GET['region']
)
)
)
)
);
According to the documentation there should be at least 1 Adult with <Person /> representing each Person within Adult. So for example :
<Adult>
<Person />
<Person />
</Adult>
For Adult no other information is needed.
At first I had problems getting it to have more than one Person within Adult.
I realised that if I stuck another array() around the elements it allowed me to have more than one.
'Adults' => array(
array('Person' => ''),
array('Person' => '')
),
This works great for Adults.
The problems comes when I have to do Children. According to documenation I believe I need Ages as mandatory in the format :
<Children>
<Person>
<Age>
<Value>8</Value>
</Age>
</Person>
</Children>
At present the code I am using :
'Children' => array(
array('Person' => array('Age' => array('Value' => 8))),
array('Person' => array('Age' => array('Value' => 10)))
),
It just is not recognising the elements Age and Value for either person. Its creating a response for the multiple persons though as follows :
<Children>
<Person />
<Person />
</Children>
The service response also says (Which may help in debugging) :
<ns0:LackingData><ns0arameterName>Children.Person.Age</ns0arameterName></ns0:LackingData>
If I change it to :
'Children' =>
array('Person' => array('Age' => array('Value' => 8))),
I get the request coming up for just the one child as needed.
<ns1:Children><ns1erson><ns1:Age><ns1:Value>8</ns1:Value></ns1:Age></ns1erson></ns1:Children>
Can anyone suggest what I am doing wrong? Im a bit lost with this now and tried every combination there is My head is now fried.
Id appreciate a bit of help on this one as I can't see me resolving it by myself think this time its beyond me.
Im assuming I am doing something wrong with the structuring of the request.
Sorry for the long post but I thought if I am going to ask for help it be best if I give as much information as possible to make it more understandable. If ive missed anything that is needed let me know and I will try provide.
Thanks for your help guys its greatly appreciated.Just to note that ive fixed it.
After 2 weeks or staying long and hard at it ive got it!
I changed the code to the following :
'Adults' => array(
0 => '',
1 => ''
),
'Children' =>
array(
0 => array('Age' => array('Value' => 8)),
1 => array('Age' => array('Value' => 10))
)
,
'Infants' => array(
array(0 => '')
)
)
It automatically picks up each person now and adds all values etc.
The request is now :
<ns1:Adults>
<ns1erson/><ns1erson/>
</ns1:Adults>
<ns1:Children>
<ns1erson><ns1:Age><ns1:Value>8</ns1:Value></ns1:Age></ns1erson><ns1erson><ns1:Age><ns1:Value>10</ns1:Value></ns1:Age></ns1erson>
</ns1:Children>
First post but I lost my details of my old account Might as well say a new hello!
Hit a bit of a problem and ive been stuck at this stage for ages now. My head has turned into mush!
Im fumbling around using the new SOAP features of PHP5 for the first time. Its all new to me. Ive been getting along nicely but Im hitting brick walls quite often in the formatting of my requests to a webservice. Ive got access to a test system for hotel bookings for practice with the documentation etc and its pretty nifty when I can get it to work.
At present I am just looking to hard code a request and then build in the dynamic details from a form.
$xmlHotels = $client->FindAvailableHotels(
array(
'SessionId' => $_SESSION['booking_session_id'],
'Operators' => array('OperatorCode' => 'XXXXXX'),
'StayDateRange' => array(
'Start' => $_GET['year'] . '-' . $_GET['month'] . '-' . $_GET['date'],
'End' => $_GET['year'] . '-' . $_GET['month'] . '-' . ($_GET['date']+$_GET['duration'])
),
'RoomStayCandidate' => array(
'GuestCounts' => array(
'PerRoom' => array(
'PerRoomRecordNumber' => '1',
'Adults' => array(
array('Person' => ''),
array('Person' => '')
),
'Children' => array(
array('Person' => array('Age' => array('Value' => 8))),
array('Person' => array('Age' => array('Value' => 10)))
),
'Infants' => array(
array('Person' => '')
)
)
)
),
'HotelSearchCriterion' => array(
'Locations' => array(
'Location' => array(
'AirportCode' => $_GET['region']
)
)
)
)
);
According to the documentation there should be at least 1 Adult with <Person /> representing each Person within Adult. So for example :
<Adult>
<Person />
<Person />
</Adult>
For Adult no other information is needed.
At first I had problems getting it to have more than one Person within Adult.
I realised that if I stuck another array() around the elements it allowed me to have more than one.
'Adults' => array(
array('Person' => ''),
array('Person' => '')
),
This works great for Adults.
The problems comes when I have to do Children. According to documenation I believe I need Ages as mandatory in the format :
<Children>
<Person>
<Age>
<Value>8</Value>
</Age>
</Person>
</Children>
At present the code I am using :
'Children' => array(
array('Person' => array('Age' => array('Value' => 8))),
array('Person' => array('Age' => array('Value' => 10)))
),
It just is not recognising the elements Age and Value for either person. Its creating a response for the multiple persons though as follows :
<Children>
<Person />
<Person />
</Children>
The service response also says (Which may help in debugging) :
<ns0:LackingData><ns0arameterName>Children.Person.Age</ns0arameterName></ns0:LackingData>
If I change it to :
'Children' =>
array('Person' => array('Age' => array('Value' => 8))),
I get the request coming up for just the one child as needed.
<ns1:Children><ns1erson><ns1:Age><ns1:Value>8</ns1:Value></ns1:Age></ns1erson></ns1:Children>
Can anyone suggest what I am doing wrong? Im a bit lost with this now and tried every combination there is My head is now fried.
Id appreciate a bit of help on this one as I can't see me resolving it by myself think this time its beyond me.
Im assuming I am doing something wrong with the structuring of the request.
Sorry for the long post but I thought if I am going to ask for help it be best if I give as much information as possible to make it more understandable. If ive missed anything that is needed let me know and I will try provide.
Thanks for your help guys its greatly appreciated.Just to note that ive fixed it.
After 2 weeks or staying long and hard at it ive got it!
I changed the code to the following :
'Adults' => array(
0 => '',
1 => ''
),
'Children' =>
array(
0 => array('Age' => array('Value' => 8)),
1 => array('Age' => array('Value' => 10))
)
,
'Infants' => array(
array(0 => '')
)
)
It automatically picks up each person now and adds all values etc.
The request is now :
<ns1:Adults>
<ns1erson/><ns1erson/>
</ns1:Adults>
<ns1:Children>
<ns1erson><ns1:Age><ns1:Value>8</ns1:Value></ns1:Age></ns1erson><ns1erson><ns1:Age><ns1:Value>10</ns1:Value></ns1:Age></ns1erson>
</ns1:Children>