PHP 5 soap and XML custom soap header

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am having a problem getting a custom soap header to work with PHP5.
What I require is something like this:

What I get is :

I would like to remove the namespace tags.
The code I use to get this is:
class Authstuff {
public $USER;
public $PASSWORD;
public function __construct($user, $pass) {
$this->USER = $user;
$this->PASSWORD = $pass;

$auth = new Authstuff('myusername', 'mypassword');
$param = array('Authstuff' => $auth);
$authvalues = new SoapVar($auth,SOAP_ENC_OBJECT);
$header = new
SoapHeader(' /',auth,$authvalues);

I have tried several other ways to do this but to no avail, using a
"null" in the namespace field returns an error.
Any help on how to do this would be great. Also could anyone recommend
a programmer for hire to help out on these problems as I will be having
quite a few in the comming weeks, not on a full time basis but to help
out with this type of question(s).

Re: PHP 5 soap and XML custom soap header

Did you modify the envelope? Your reference to the namespace brings up
a page (with tons of popups) and not your namespace.

Did you try

new SoapClient(null,


new SoapClient("null",  

The first one is the correct one.

Re: PHP 5 soap and XML custom soap header

That should have been "Your reference to the envelope" :)

Re: PHP 5 soap and XML custom soap header

I thank you for your reply, Sorry about the popup page, not sure how
that got in there.
I am currently using the following:
$param = array('Authstuff' => $auth);
$auth = new authstuff('myuser','mypassword');
$authvalues=new SoapVar($auth,SOAP_ENC_OBJECT);
$header = new
SoapHeader(" /",notneeded,$authvalues);

$client = new SoapClient(null,
        "location" => "http://localhost:8181/devserv",
        "uri"      => "",
        "style"    => SOAP_RPC,
        "use"      => SOAP_ENCODED
and getting:
                <PASSWORD> mypassword</PASSWORD>

Any idea how to get rid of the ":notneeded" parts, if I put them as
null I get:
Fatal error: SoapHeader::__construct(): Invalid parameters. Invalid
header name.

any help appreciated

Re: PHP 5 soap and XML custom soap header

hmmm, null has worked for me in the past. My current host doesn't have
soap so.....

Maybe the following will work

 SoapHeader(" /", ,$authvalues)

Site Timeline