note 98082 added to class.soapserver

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
As the SoapServer class lacks the possibility of dealing with SOAP-Headers, my following workaround is suitable to my needs when I had to do authentication via the SOAP-Headers:
1. Use a class which handles SOAP requests and let the constructor of this class take the sent headers.
2. Before invoking the SoapServer extract the SOAP-Header from the incoming raw data.
3. When using setClass pass the extracted header to the handling class.

In Your Server-Skript do things like this 
<?php
$hdr = file_get_contents("php://input");
if (strpos($hdr,'<s:Header>')===false) {
	$hdr = null;
} else {
	$hdr = explode('<s:Header>',$hdr);
	$hdr = explode('</s:Header>',$hdr[1]);
	$hdr = $hdr[0];
}
$srv = new SoapServer('Your_wsdl');
$srv->setClass("ServiceClass",$hdr);
$srv->handle();
?>

And the service class is like this:
<?php
class ServiceClass {
	var $IsAuthenticated;

	function __construct($hdr) {
		$this->IsAuthenticated = false;
		if ($hdr!=null) {
			$this->header = simplexml_load_string($hdr);
			//Your authentication stuff goes here...
		}
	}
	
	function SomeFunctionOfTheService($a) {
		if ($this->IsAuthenticated) {
			//here Your function...
		}
	}

}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 217.230.13.172
----
Manual Page -- http://www.php.net/manual/en/class.soapserver.php
Edit        -- https://master.php.net/note/edit/98082
Del: integrated  -- https://master.php.net/note/delete/98082/integrated
Del: useless     -- https://master.php.net/note/delete/98082/useless
Del: bad code    -- https://master.php.net/note/delete/98082/bad+code
Del: spam        -- https://master.php.net/note/delete/98082/spam
Del: non-english -- https://master.php.net/note/delete/98082/non-english
Del: in docs     -- https://master.php.net/note/delete/98082/in+docs
Del: other reasons-- https://master.php.net/note/delete/98082
Reject      -- https://master.php.net/note/reject/98082
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.