php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51751 Adding header to SOAPFault
Submitted: 2010-05-05 21:45 UTC Modified: 2010-05-05 22:12 UTC
From: daniuf at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.13 OS: CentOS
Private report: No CVE-ID: None
 [2010-05-05 21:45 UTC] daniuf at gmail dot com
Description:
------------
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
               }
}

?>

Expected result:
----------------
Response:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<ns2:Transaction>
<TransactionId>5553</TransactionId>
</ns2:Transaction>
</env:Header>
<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>

Actual result:
--------------
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>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-05 22:07 UTC] degeberg@php.net
-Status: Open +Status: Bogus
 [2010-05-05 22:07 UTC] degeberg@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2010-05-05 22:12 UTC] danbrown@php.net
daniuf:  When I rejected your note, it was to bring to your attention the various 
support channels.  Those *do not* include the user notes sections or this 
bugtracker.

Please submit your request for assistance to the PHP General mailing list, to 
which you may subscribe at http://php.net/mailinglists .

Thanks.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jun 14 13:01:23 2021 UTC