note 98082 added to class.soapserver
| From: | junk2cm at gmx dot de | Date: | Tue, 25 May 2010 07:54:35 +0000 |
| Subject: | note 98082 added to class.soapserver | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169578@lists.php.net to get a copy of this message | ||
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