note 97737 added to soapfault.soapfault

From: Date: Wed, 05 May 2010 19:21:25 +0000
Subject: note 97737 added to soapfault.soapfault
Groups: php.notes 
Request: Send a blank email to php-notes+get-168982@lists.php.net to get a copy of this message
I'm developing a Web Service using the SOAP class with WSDL mode on. I'm having problems when I need to add Headers to the Soap Fault response, and looked examples everywhere, but I haven't found them. As documentation says, the sixth parameter of the SoapFault constructor is the one that should do this, but although I did so, no headers have been added to my SoapFault response. I add the code below, as well as an example of my Request/Response. <?php /** * class Transaction * * @param $TransactionId = string */ class Transaction { public $TransactionId; function __construct($Transaction){ $this->TransactionId = $Transaction; } } /** * class soapdetail * Class to create a Fault Detail * @param $ID = string. Error Number. * @param $Description = string. Short description about occurred error. */ class soapdetail { public $ID; public $Description; function __construct($codigo, $detalle){ $this->ID = $codigo; $this->Description = $detalle; } } class WSSuscripciones { /** * method consulta * * @param object $NumeroLinea * */ public function consulta($NumeroLinea) { if (!$this->authenticated) { $soap = new soapdetail("2","Las credenciales no estan autorizadas para realizar esta consulta."); $transaction = new Transaction($this->TransactionId); $authvalues = new SoapVar($transaction, SOAP_ENC_OBJECT); $header = new SoapHeader('My WSDL URL', 'Transaction', $authvalues); throw new SOAPFault("soap:Server", "Las credenciales no estan autorizadas para realizar esta consulta.", "My WSDL URL", $soap, "Transaction", $header); } else { //do something } } ?> Request: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/" xmlns:ns2="My WSDL URL"> <env:Header> <ns2:Transaction> <TransactionId>5553</TransactionId> </ns2:Transaction> <ns2:Authentication> <UserName>telecom</UserName> <Password>WSuscr1pc10n3sd</Password> </ns2:Authentication> </env:Header> <env:Body> <ns1:consulta> <ns1:NumeroLinea>1111111111</ns1:NumeroLinea> </ns1:consulta> </env:Body> </env:Envelope> Response: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body> <env:Fault> <env:Code> <env:Value>soap:Server</env:Value> </env:Code> <env:Reason> <env:Text>Las credenciales no estan autorizadas para realizar esta consulta.</env:Text> </env:Reason> <env:Detail> <ID>2</ID> <Description>Las credenciales no estan autorizadas para realizar esta consulta.</Description> </env:Detail> </env:Fault> </env:Body> </env:Envelope> ---- Server IP: 201.216.232.3 Probable Submitter: 201.216.209.53 ---- Manual Page -- http://www.php.net/manual/en/soapfault.soapfault.php Edit -- https://master.php.net/note/edit/97737 Del: integrated -- https://master.php.net/note/delete/97737/integrated Del: useless -- https://master.php.net/note/delete/97737/useless Del: bad code -- https://master.php.net/note/delete/97737/bad+code Del: spam -- https://master.php.net/note/delete/97737/spam Del: non-english -- https://master.php.net/note/delete/97737/non-english Del: in docs -- https://master.php.net/note/delete/97737/in+docs Del: other reasons-- https://master.php.net/note/delete/97737 Reject -- https://master.php.net/note/reject/97737 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168982) next »