note 105448 modified in class.soapserver by danbrown
| From: | danbrown@php.net | Date: | Thu, 18 Aug 2011 20:45:50 +0000 |
| Subject: | note 105448 modified in class.soapserver by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182578@lists.php.net to get a copy of this message | ||
While there are plenty of mentions online that SoapServer doesn't support SOAP Headers, this
isn't true.
In your class, if you declare a function with the name of the header, the function will be called
when that header is received.
<?php
class MySoapService {
private $user_is_valid;
function MyHeader($header) {
if ((isset($header->Username)) && (isset($header->Password))) {
if (ValidateUser($header->Username, $header->Password)) {
$user_is_valid = true;
}
}
}
funstion MySoapRequest($request) {
if ($user_is_valid) {
// process request
}
else {
throw new MyFault("MySoapRequest", "User not valid.");
}
}
}
?>
--was--
While there are plenty of mentions online that SoapServer doesn't support SOAP Headers, this
isn't true.
In your class, if you declare a function with the name of the header, the function will be called
when that header is received.
<?php
class MySoapService {
private $user_is_valid;
function MyHeader($header) {
if ((isset($header->Username)) && (isset($header->Password))) {
if (ValidateUser($header->Username, $header->Password)) {
$user_is_valid = true;
}
}
}
funstion MySoapRequest($request) {
if ($user_is_valid) {
// process request
}
else {
throw new MyFault("MySoapRequest", "User not valid.");
}
}
}
http://php.net/manual/en/class.soapserver.php