To build the authentication headers like below FOR WSDL:
**NOTE** I cannot find documentation on the __setSoapHeaders() method, though it does work in 5.0.4
<?php
class MySoapClass
{
function __construct(){
// Blah blah blah
$this->soap = new SoapClient($this->foo, $this->bar);
}
// Build that header!
private function build_auth_header(){
// Build an object with parameters
$auth->username = $this->username;
$auth->password = $this->password;
$authvalues = new SoapVar($auth, SOAP_ENC_OBJECT);
$header = new SoapHeader($this->name_space, "Authentication", // Rename this to the tag you need
$authvalues, false);
$this->soap->__setSoapHeaders(array($header));
}
// Wrapper so we can build auth header first
public function MySoapFunction($params){
$this->build_auth_header();
$this->soap->MySoapFunction($params);
}
}
?>