Hi List
I have been given a rather urgent problem to solve for one of our clients. I
have to be able to connect to a server that deals with a section of the travel
industry and send and receive XML data. The API is quite poorly written and I am
finding it hard to get sense out of the companies help desk. I would appreciate
the help of the list in getting me pointed in the right direction.
The API expects a custom header and then a request. I have built the header and
I think it is OK. The request is an XML request and this is where I believe I am
having problems. I am getting an error response from the server telling me I
have invalid XML.
I am really stumped with the XML part. I have no idea how to code this section
and it appears what I am doing is not correct. I have spent days searching the
net looking for clues and so far have not succeeded.
I would appreciate help and guidance. If anyone needs any more information
please do not hesitate to ask.
This is what I have so far (note I have hidden usernames and passwords)
<?php
$url = "stagingxml.infosys.de";
$port = "10816";
/*
* HTTP Header Components
* Each part of the custom header is defined in the API document
*/
$length = "Content-Length: 502";
$a_encoding = "Accept-Encoding: gzip";
$t_encoding = "Transfer-Encoding: identity";
$accessmode = "Accessmode: agency";
$accessid = "Accessid: XXXXXXX XXXXXXX_layout";
$accept = "Accept: application/xml";
$charset = "Accept-Charset: iso-8859-1, utf-8";
$host = $test_url;
$session = "Session: ";
$api = "Api-Version: 3.4";
$connection = "Connection: Close";
$authorization = "Authorization: A Base 64 representation of username,
password";
$authmode = "Authmode: pwd";
/*
* Build HTTP Header to use in CURLOPT_HTTPHEADER
*/
$headers[] = $length;
$headers[] = $a_encoding;
$headers[] = $t_encoding;
$headers[] = $accessmode;
$headers[] = $accessid;
$headers[] = $accept;
$headers[] = $charset;
$headers[] = $session;
$headers[] = $api;
$headers[] = $connection;
$headers[] = $authorization;
$headers[] = $authmode;
$xmlstr = '<?xml version="1.0" encoding="UTF-8"?><fareRequest
da="false"><vcrs/><fareTypes/><tourOps/><flights><flight depApt="FRA"
dstApt="LON" depDate="2007-01-26"/></flights><paxes><pax surname="Smith"
firstname="John" dob="1945-12-12"
gender="M"/></paxes><paxTypes/><options><limit>20</limit><offset>0</offset><waitOnList><waitOn>ALL</waitOn></waitOnList></options><coses/></fareRequest>';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_PORT, $port);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, urlencode($xmlstr));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 40);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
$response = curl_exec($curl);
if(curl_errno($curl))
{
print curl_error($curl);
}
else
{
curl_close($curl);
}
print "$response\n\n\n";
?>
I thank you in advance for any help.
Regards,
Richard Luckhurst
Exodus Systems - Sydney, Australia.
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php