Sunday, 28 December 2014

Send XML SOAP request from HTML form



I am trying to send a SOAP request from a HTML form. My form has 6 fields as below:



City: - text
Check-in - text/date
Check-Out - text/date
Rooms - Selector (1, 2, 3, 4, 5)
Adults - Selector (1, 2, 3, 4, 5)
Childs - Selector (0, 1, 2, 3, 4)


The cookies that i receive are



$In= $_POST['In'];
$Out= $_POST['Out'];
$City= $_POST['City'];
$Rooms= $_POST['Rooms'];
$Adults= $_POST['Adults'];
$Childs= $_POST['Childs'];


The response page have a SOAP client connection Example:



// create SOAP client object
$client = new SoapClient("./book.wsdl", array('trace' => 1));
try {
$rooms = array();

// request with 1 room and 2 adults selected
$rooms[] = array(array("paxType" => "Adult"), array("paxType" => "Adult"));


$filters = array();
$filters[] = array("filterType" => "hotelStar", "filterValue" => "5");

$filters[] = array("filterType" => "resultLimit", "filterValue" => "4");

// make getAvailableHotel request (start search)
$checkAvailability = $client->getAvailableHotel("3QXNHSXZRYUZOb095Qg==", "$City", "$In", "$Out", "EUR", "RO", "false", $rooms, $filters);


How can i translate the response from the form selector value into the request page as show below:



// request with 1 room and 2 adults selected

$rooms[] = array(array("paxType" => "Adult"), array("paxType" => "Adult"));


Thanks.


No comments:

Post a Comment