Jeg ved ikke om det her kan bruges men jeg udviklede det fordi jeg ikke lige havde SOAP på min server og brugte istedet det her:
xmlrpc.obj.php:
<?php
class XMLRPCClient
{
var $connection = false;
var $host = false;
var $action = false;
var $xml_to_send =false;
var $path;
public function __construct($host, $path = "", $port = 80)
{
if(!$this->connection = fsockopen($host, $port, $errno, $errstr, 30))
{
throw new Exception("<b>XMLRPCCLient - Could not open host</b>:<br />Error no is <b>".$errnr."</b><br />Error message is <b>".$errstr."</b>");
return false;
}
if(strpos($path, "/") === 0)
$path = substr($path, 1);
$this->host = $host;
$this->path = $path;
}
public function setData($xml)
{
$this->xml_to_send = $xml;
}
public function setAction($action)
{
$this->action = $action;
}
public function exec()
{
if($this->_validate())
return $this->_sendXML();
else
return false;
}
private function _sendXML()
{
$data = $this->_createSendString();
$response = "";
fwrite($this->connection, $data);
while (!feof($this->connection)) {
$response .= fgets($this->connection, 128);
}
if(($start = strripos($response, "<?xml")) !== false)
{
$response = substr($response, $start);
}
else
{
$response = "<b>Response was not XML</b>";
}
return $response;
}
private function _createSendString()
{
$content_length = strlen($this->xml_to_send);
$data = "POST /".$this->path." HTTP/1.0\n";
$data .= "User-Agent: xmlrpc-epi-php/0.2 (PHP)\n";
$data .= "Host: ".$this->host."\n";
$data .= "Content-Type: text/xml; charset=utf-8\n";
$data .= "Content-Length: ".$content_length."\n";
if($this->action !== false)
$data .= "SOAPAction: \"".$this->action."\"\n";
$data .= "Connection: close\n\n";
$data .= $this->xml_to_send;
return $data;
}
private function _validate()
{
if(!$this->connection)
{
throw new Exception("<b>XMLRPCCLient:</b> Connection has not been established");
return false;
}
if(!$this->xml_to_send)
{
throw new Exception("<b>XMLRPCCLient:</b> XML to send has not been set");
return false;
}
return true;
}
public function __destruct()
{
fclose($this->connection);
}
}
?>
Og så bruger jeg den således:
<?php
include("xmlrpc.obj.php");
// Tilret selv relevante data
$xml = "
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope xmlns:xsi=\"
http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"
http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"
http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body>
<SendSMS xmlns=\"
http://service.yourhost.dk/smsgateway/\"> <username>string</username>
<password>string</password>
<phoneNo>string</phoneNo>
<message>string</message>
<flashSMS>false</flashSMS>
</SendSMS>
</soap:Body>
</soap:Envelope>
";
try
{
$client = new XMLRPCClient("service.yourhost.dk", "smsgateway/Default.asmx");
$client->setAction("
http://service.yourhost.dk/smsgateway/SendSMS");
$client->setData(trim($xml));
echo $client->exec(); //obj::exec() returnerer svaret fra servicen
}
catch (Exception $e)
{
echo $e;
}
?>
Scriptet er gammelt, men virker da stadigvæk (hurtigt testet) men der er sikkert en pænere måde at gøre det på end det jeg har skrevet...