';
?>
Test POST/SOAP Communication for CSW/WFS
asXML();
$headers = array(
"POST ".$path." HTTP/1.1",
"Content-type: text/xml; charset=\"utf-8\"",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: ".strlen($datanew)
);
if ($doSOAP) {
$soapHead = "\n";
$soapHead .= "\n";
$soapHead .= "\n";
$soapFoot = "\n";
$soapFoot .= "\n";
$data = $soapHead.$data.$soapFoot;
$dataXMLObject = new SimpleXMLElement($data);
$datanew = $dataXMLObject->asXML();
$headers = array(
"POST ".$path." HTTP/1.1",
"Content-type: application/soap+xml; charset=\"utf-8\"",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($datanew)
);
}
//do curl connection and request
$out = getCURL($_REQUEST["onlineresource"],$datanew,$headers,$doSOAP);
}
//of class_connector
function getCURL($url,$data,$headers,$doSOAP){
$ch = curl_init ($url);
$arURL = parse_url($url);
$host = $arURL["host"];
$port = $arURL["port"];
if($port == ''){
$port = 80;
}
$path = $arURL["path"];
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
//or with own headers
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$NOT_PROXY_HOSTS_array = explode(",", NOT_PROXY_HOSTS);
//check if http_proxy is set as env, if yes, unset it for the curl action here, it will be reset somewhere below - normally not needed, cause it will be only available when at execution time of the script http://php.net/manual/en/function.putenv.php
if (getenv('http_proxy')) {
$e = new mb_notice("class_connector.php: current http_proxy: ".getenv('http_proxy')." will be unset by putenv('http_proxy')");
$tmpHttpProxy = getenv('http_proxy');
putenv("http_proxy"); //this should unset the variable???
} else {
$e = new mb_notice("class_connector.php: http_proxy is not set as env variable!");
$tmpHttpProxy = getenv('http_proxy');
}
//check if proxy is set and server not in NOT_PROXY_HOSTS
if(CONNECTION_PROXY != "" AND (in_array($host, $NOT_PROXY_HOSTS_array)!= true)){
curl_setopt($ch, CURLOPT_PROXY,CONNECTION_PROXY.":".CONNECTION_PORT);
$e = new mb_notice("class_connector.php: Proxy will be used!");
if(CONNECTION_PASSWORD != ""){
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, CONNECTION_USER.':'.CONNECTION_PASSWORD);
}
} else {
$e = new mb_notice("class_connector.php: Proxy will not be used!");
}
if(CONNECTION_PASSWORD != ""){
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, CONNECTION_USER.':'.CONNECTION_PASSWORD);
}
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$useragent='GeoPortal Rheinland-Pfalz Testsystem';
curl_setopt ($ch,CURLOPT_USERAGENT,$useragent);
$file = curl_exec ($ch);
curl_close ($ch);
$e = new mb_exception("send_post_curl.php: url " . $url);
$e = new mb_exception("send_post_curl.php: send post " . $data);
$e = new mb_exception("send_post_curl.php: response " . $file);
return $file;
}
?>