dismiss Step into the future! Click here to switch to the beta php.net site
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

SoapHeader::__construct> <SoapFault::__toString
[edit] Last updated: Fri, 28 Jun 2013

view this page in

The SoapHeader class

(PHP 5 >= 5.0.1)

Introduction

Represents a SOAP header.

Class synopsis

SoapHeader {
/* Methods */
__construct ( string $namespace , string $name [, mixed $data [, bool $mustunderstand [, string $actor ]]] )
SoapHeader ( string $namespace , string $name [, mixed $data [, bool $mustunderstand = false [, string $actor ]]] )
}

Table of Contents



add a note add a note User Contributed Notes SoapHeader - [2 notes]
up
1
john at jtresponse dot co dot uk
1 year ago
None of the examples really do it for me.
Note: you should NOT need to hard-code any XML.

Here is an example of creating a nested header and including a parameter.

$client = new SoapClient(WSDL,array());

$auth = array(
        'UserName'=>'USERNAME',
        'Password'=>'PASSWORD',
        'SystemId'=> array('_'=>'DATA','Param'=>'PARAM'),
        );
  $header = new SoapHeader('NAMESPACE','Auth',$auth,false);
  $client->__setSoapHeaders($header);

Gives the following header XML:

  <SOAP-ENV:Header>
    <ns1:Auth>
      <ns1:SystemId Param="PARAM">DATA</ns1:SystemId>
      <ns1:UserName>USERNAME</ns1:UserName>
      <ns1:Password>PASSWORD</ns1:Password>
    </ns1:Auth>
  </SOAP-ENV:Header>
up
0
jstilow at mobileobjects dot de
1 year ago
It cost me some time to figure out how to add a SoapHeader to a server response. For me the following solution works well enough:

<?php
class SoapService {
    private
$server = null;

    public function
__construct($server)
    {
       
$this->server = $server;
    }

    public function
soap($request) {
       
// do something useful

        // These are the two "magic" lines:
       
$header = new SoapHeader("namespace", "name", new HeaderClass("possible some parameters"));
       
$this->soap_server->addSoapHeader($header);

       
// do more useful stuff
   
}
}

$soap_server = new SoapServer("./your.wsdl");
$soap_server->setClass("SoapService", $soap_server);
$soap_server->handle();
?>

See also:
https://bugs.php.net/bug.php?id=32410

 
show source | credits | stats | sitemap | contact | advertising | mirror sites