SOAP with php : how to catch core notice

Moderator: crythias

Locked
benoitm
Znuny newbie
Posts: 34
Joined: 21 Mar 2011, 10:22
Znuny Version: 3.0.6

SOAP with php : how to catch core notice

Post by benoitm »

Hi every one !

First sorry for my bad english, I'm French :)

I'm begginer with OTRS and Php. I want to use SOAP interface to integrate OTRS client directly on my website. So i decided to create a php class with all functions i will need to do that.

here is my construct function (php) :

Code: Select all

class PhpSoap{
			
	var $soapclient;
	var $soap_error = false;
	var $user = "remote_user";
	var $pass = "****";
	var $url = "http://****/otrs/rpc.pl";
				

	function __construct() {
		// Pour supprimer le cache du web-service
		ini_set('soap.wsdl_cache_enabled', 0);
		// Pour définir le temp maximal d'éxecution de notre web-service
		ini_set('default_socket_timeout', 180);
		$error = false;
		   
		try{
			$this->soapclient = new SoapClient(null, array('location'  => $this->url,
			'uri'       => "Core",
			'trace'     => 1,
			'login'     => $this->user,
			'password'  => $this->pass,
			'style'     => SOAP_RPC,
			'use'       => SOAP_ENCODED));
									

			return $this->soapclient;
		}
		catch(SoapFault $soap_error){
			$error = true;
			$this->soap_error = $soap_error;
			echo "<hr/>".$soap_error."<hr/>";
		}
		
	}

$otrs = new PhpSoap();
That is good making good connection to my remote OTRS system.
But if I write a wrong password/username, no error are catch, but in my otrs log I can see :

Code: Select all

[Mon Mar 21 09:18:39 2011][Notice][Core::Dispatch] Auth for user remote_user (pw test) failed!
My first question is : how can I catch this warning with SOAP / PHP to use it and let my visitor know if, for example, my otrs system if not available / offline ?

Thanks a lot
Locked