Page 1 of 1

HTTP Post with xml Document

Posted: Mon Nov 08, 2010 12:36 am
by nivas41
HI All

I am very much new to PHP programmng. I am having requirement that I can call web API Through HTTP POST with with XML file.

I tried with

Code: Select all

	$url=" https://site.one.com";
	$post_string='<requestEnvelope xmlns="http://services.xyz.com/infoset"> <header> <credentials>    <userNameAndPassword> <name>satya</name> <password>xcvfder</password> </userNameAndPassword> </credentials> </header> <requests> <request tag="0:Network.GetSites()"> <service>network</service> <operation>getSites</operation> <arguments> <network id="1651410" /> </arguments> </request> </requests> </requestEnvelope>';

	$header = 'POST HTTP/1.0 \r\n';
	$header .= 'Content-type text/xml \r\n';
	$header .= 'Content-length: ".strlen($post_string)." \r\n';
	$header .= "Content-transfer-encoding: text \r\n";
	$header .= "Connection: close \r\n\r\n";
	$header .= $post_string;

                 curl_init(); 
                 curl_setopt($ch, CURLOPT_URL, $url);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
	curl_setopt($ch, CURLOPT_TIMEOUT, 4);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 0);
	
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $header);
	
	$data = curl_exec($ch);
	
	if(curl_errno($ch))
		print curl_error($ch);
	else
		curl_close($ch);
functions and getting errow like below
'Protocol https not supported or disabled in libcurl !!! '

is there any other methods to post xml ..

Please guide me .. Thanks in advance for your help

Satya

Re: HTTP Post with xml Document

Posted: Mon Nov 08, 2010 6:59 am
by s.dot
You could try just regular post headers without curl.
Open a filestream, post the headers to it, and read back the response.