Source: tinysoap.phps - download
<?php


    
    
//tinySoap usage
    
$wsdl        'http://www.webservicex.com/globalweather.asmx?wsdl';
    
$call         'GetWeather';
    
$vars        = array('CityName'=>'Riyadh','CountryName'=>'Saudi Arabia');
    
$headers    = array();
    
$xmlns         'http://www.webserviceX.NET';
    
    
$data tinySoap($wsdl$call$vars$headers$xmlns);
    
print_r($data);


//TinySOAP by daif (http://daif.net/script/tinysoap.phps)
function tinySoap($wsdl$call$vars=array(), $headers=array(), $xmlns='http://tempuri.org/') {
    
//post data
    
$post_data  '<?xml version="1.0" encoding="utf-8"?>'."\r\n";
    
$post_data .= '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'."\r\n";
    if(
is_array($headers) && count($headers)>0) {
        
$post_data .='  <soap12:Header>'."\r\n";
        foreach(
$headers as $header_k=>$header_v) {
            
$post_data .='    <'.$header_k.' xmlns="'.$xmlns.'">'."\r\n";
            foreach(
$header_v as $k=>$v) {
                
$post_data .='      <'.$k.'>'.$v.'</'.$k.'>'."\r\n";
            }
            
$post_data .='    </'.$header_k.'>'."\r\n";
        }
        
$post_data .='  </soap12:Header>'."\r\n";
    }
    
$post_data .= '  <soap12:Body>'."\r\n";
    
$post_data .= '    <'.$call.' xmlns="'.$xmlns.'">'."\r\n";
    foreach(
$vars as $k=>$v) {
        
$post_data .= '      <'.$k.'>'.$v.'</'.$k.'>'."\r\n";
    }
    
$post_data .= '    </'.$call.'>'."\r\n";
    
$post_data .= '  </soap12:Body>'."\r\n";
    
$post_data .= '</soap12:Envelope>';
    
//header
    
$url parse_url($wsdl);
    
$header[]= 'POST '.$url['path'].' HTTP/1.1';
    
$header[]= 'Host: '.$url['host'];
    
$header[]= 'Content-Type: text/xml; charset=utf-8';
    
$header[]= 'Content-Length: '.strlen($post_data);
    
//send request
    
$ch curl_init($wsdl);
    
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
    
curl_setopt($ch,CURLOPT_POST,TRUE);
    
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
    
curl_setopt($chCURLOPT_POSTFIELDS,$post_data);
    
$response curl_exec($ch);
    
//convert xml2array
    
$response preg_replace("/(<\/?)(\w+):([^>]*>)/""$1$2$3"$response);
    
$response json_decode(json_encode(simplexml_load_string($response)),true);
    
curl_close($ch);
    if(isset(
$response['soapBody']['soapFault'])) {
        
$return $response['soapBody']['soapFault'];
    } else {
        
$return $response['soapBody'][$call.'Response'][$call.'Result'];
    }
    
$functionResponse $call.'Response';
    if(
function_exists($functionResponse)){
        return(
$functionResponse($return));
    } else {
        return(
$return);
    }
}

?>