Hi
Could you help me to translate this PHP code to PowerBuilder.
It is used to call a REST-type web service.
Thanks for your help.
Thierry
DEFINE('CFG_APP_ID', '???????????');
DEFINE('CFG_TOKEN', '?????????????????');
function CallWebService($strCallURL, $strMethod, $strBody, &$bResult){
$strURL = $strCallURL;
$strParams = 'Data=' . urlencode($strBody);
$strParams .= '&AppId=' . urlencode(CFG_APP_ID);
$strParams .= '&Token=' . urlencode(CFG_TOKEN);
$strParams .= '&Method=' . urlencode($strMethod);
$objCurl = curl_init();
curl_setopt($objCurl, CURLOPT_URL, $strURL);
curl_setopt($objCurl, CURLOPT_POST, 1);
curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($objCurl, CURLOPT_POSTFIELDS, $strParams);
curl_setopt($objCurl, CURLOPT_HTTPHEADER,
array("Content-Type: application/x-www-form-urlencoded", "Content-length: " . strlen($strParams)));
$strResponse = curl_exec($objCurl);
if ( !curl_errno($objCurl) ) {
$bResult = true;
} else {
$bResult = false;
$strResponse = 'An error occured: ' . curl_error($objCurl);
}
return $strResponse;
}
//call function
$strResponse =
CallWebService('https://webservices.oxatis.com/WebServices/httpservices/productservices.aspx' ,
'ProductGet',
'<?xml version="1.0" encoding="utf-8"?> <Product xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><OxID>9999999</OxID></Product>', $bResult);
if ( $bResult ) {
header("Content-type: text/xml");
}
echo $strResponse;
?>