note 91297 modified in function.curl-setopt by danbrown

From: Date: Thu, 04 Jun 2009 12:34:33 +0000
Subject: note 91297 modified in function.curl-setopt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-156352@lists.php.net to get a copy of this message
if you need to send a SOAP string that is the CURL you must use : <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, XML_POST_URL); curl_setopt ($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD); curl_setopt($ch, CURLOPT_HEADER, 0); $output = curl_exec($ch); ?> Note : Having based my snipet on Chemo demonstration (oscommerce user know who he is), XML_POST_URL and XML_PAYLOAD where defined as constant with define(). The point is : at the opposite of .xml , SOAP must send the header 'SOAPAction: ""' that can be a valid URI, an empty string (that is here) or nothing ('SOAPAction: '). The later case baing not accepted by all server, the second one indicating the target is the URI used to post the SOAP. http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528 --was-- if you need to send a SOAP string that is the CURL you must use : $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, XML_POST_URL); curl_setopt ($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_POSTFIELDS, XML_PAYLOAD); curl_setopt($ch, CURLOPT_HEADER, 0); $output = curl_exec($ch); Note : Having based my snipet on Chemo demonstration (oscommerce user know who he is), XML_POST_URL and XML_PAYLOAD where defined as constant with define(). The point is : at the opposite of .xml , SOAP must send the header 'SOAPAction: ""' that can be a valid URI, an empty string (that is here) or nothing ('SOAPAction: '). The later case baing not accepted by all server, the second one indicating the target is the URI used to post the SOAP. http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528 http://php.net/manual/en/function.curl-setopt.php

« previous php.notes (#156352) next »