views:

25

answers:

1

I've a complete SOAP envelope (XML) ready. What would be the easiest way to send this envelope in php? I know about SoapClient and Zend_Soap_Client but please consider this particular case, where I just want to send this envelope and print the xml response.

//Pseudo function for what I wanna do
public function sendEnvelope($xmlEnvelope, $url)
{
  //send this envelope to $url
  //return response
}
+1  A: 

If you've got the Zend Framework to hand you could perhaps do something like:

$client = new Zend_Http_Client();
$client->setUri($url);
$client->setMethod(Zend_Http_Client::POST);
$client->setRawData($xmlEnvelope, 'application/soap+xml');
$response = $client->request();

Alternatively you can use cURL with a good introduction available at Techniques for Mastering cURL from Nettus+

Alistair
Your Zend solution with setHeaders() worked great.
understack