By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 IT Pros & Developers. It's quick & easy.

PHP 5 soap and XML custom soap header

P: n/a
Hello,
I am having a problem getting a custom soap header to work with PHP5.
What I require is something like this:
<SOAP-ENV:Header>
<USER>myusername</USER>
<PASSWORD>mypassword</PASSWORD>
</SOAP-ENV:Header>

What I get is :
<SOAP-ENV:Header>
<ns2:auth>
<USER>myusername</USER>
<PASSWORD>mypassword</PASSWORD>
</ns2:auth>
</SOAP-ENV:Header>

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('http://soapinterop.org/echoheader/',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).

Cheers,
Harv

Sep 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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,

or

new SoapClient("null",

The first one is the correct one.

Sep 15 '05 #2

P: n/a
That should have been "Your reference to the envelope" :)

Sep 15 '05 #3

P: n/a
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("http://schemas.xmlsoap.org/soap/envelope/",notneeded,$authvalues);

$client = new SoapClient(null,
array(
"location" => "http://localhost:8181/devserv",
"uri" => "",
"style" => SOAP_RPC,
"use" => SOAP_ENCODED
));
and getting:
<SOAP-ENV:Header>
<SOAP-ENV:notneeded>
<USER>myuser</USER>
<PASSWORD> mypassword</PASSWORD>
</SOAP-ENV:notneeded>
</SOAP-ENV:Header>

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

Sep 16 '05 #4

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

Maybe the following will work

SoapHeader("http://schemas.xmlsoap.org/soap/envelope/", ,$authvalues)

Sep 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.