I am totally new to REST web services.I am in need to post some information to the REST web service and get the response which contains the detail of a job posting.The response and request is in xml format.I got some xml code from a developer and he said that he is using this xml to retrieve the details.
The xml code is
[CODE]<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:ws=”http://ws.mrted.com/”>
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand=”1″ xmlns:wsse=”http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd” xmlns:wsu=”http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd”>
<wsse:UsernameToken wsu:Id=”UsernameToken-1″>
<wsse:Username>PSHFK026203F3VB8MLO798NLD:guest:FO</wsse:Username>
<wsse:Password Type=”http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText”>guest</wsse:Password>
<wsu:Created>2012-07-09T11:35:20.019Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ws:getAdvertisementById>
<ws:postingTargetId>6337</ws:postingTargetId>
<ws:langCode>UK</ws:langCode>
</ws:getAdvertisementById>
</soapenv:Body>
</soapenv:Envelope>
Now the question is,
1.How this code has been generated?
My php code is,
[code=php]$host = “https://apiurl?api_key=dabc4dvptajdnrhwnqsfxxxx”;
$username = “guest”;
$password = “guest”;
$getjobdetail = ‘<?xml version=”1.0″ encoding=”utf-8″?><getAdvertisementById>
<postingTargetId>6337</postingTargetId>
<langCode>UK</langCode>
</getAdvertisementById>’;
$headers = array();
$headers[] = ‘Accept: application/xml’;
$headers[] = ‘Content-Type: application/xml; charset=UTF-8’;
$process = curl_init($host);
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERPWD, $username . “:” . $password);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_POSTFIELDS, $getjobdetail);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($process);
echo ‘<pre>’;
print_r($return);
echo ‘</pre>’;
curl_close($process);
2.Also for the username do I need to use
[code=php]$username = ‘PSHFK026203F3VB8MLO798NLD:guest:FO’
or just
[code=php]$username = ‘guest’;
Please suggest how should I proceed and if I am on the right path.Many thanks in advance.