note 116074 deleted from class.soapclient by salathe
| From: | salathe@php.net | Date: | Fri, 07 Nov 2014 11:17:23 +0000 |
| Subject: | note 116074 deleted from class.soapclient by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200835@lists.php.net to get a copy of this message | ||
Note Submitter: prabowo[dot]priyo[at]gmail.com
----
Using Zimbra 8.5 server as SOAP server i found that you first need to authenticate yourself using
authRequest then using authToken from the authResponse to form a header. Without a valid SOAPHeader
you will get "no valid authtoken present" error.
BTW, you may be don't need this if you are running the php scripts on the same server with
zimbra
<?php
//Predefined variables
$S = array(
"server" => "mail.b-studio.web.id",
"username" => "admin",
"password" => "mypassword"
);
try{
$S["client"] = new soapclient('https://'.$S["server"].'/service/wsdl/ZimbraAdminService.wsdl');
$response =
$S["client"]->authRequest(array("name"=>$S['username'],"password"=>$S['password']));
$S["authToken"] = $response->authToken;
$S["header"] = new
SOAPHeader("urn:zimbra","context",array("authToken"=>$S["authToken"]));
$S["client"]->__setSoapHeaders($S["header"]);
$response=$S["client"]->GetAllCosRequest();
var_dump($response);
}catch (Exception $e){
echo "Exception: {$e->getMessage()}\n";
}
?>