-----Original Message-----
From: anthony@acolebourne.co.uk [mailto:anthony@acolebourne.co.uk]
Hi,
I've wrote a PEAR::SOAP web service server and I've protected it using a htaccess file Basic Authentication.
I cannot get my PEAR::SOAP Client working.
I've tried addHeader(), however I don't know that parameters I should use to create the SOAP_Header.
I realized that HTTP Basic authentication was handled in the HTTP header, not the SOAP header!!
Therefore all you need to do in PHP is:
header("Authorization: Basic ".base64_encode("username:password"));
before you send the soap message. The beauty of this is that the actual 'challenge' part of the authentication can be handles by Apache using a .htaccess file.
Unfortunately I don't know if there is a way to specify this requirement in the WSDL. The benefit of SOAP is that it builds on existing protocols like HTTP, Basic authentication (and Digest) is an important part of HTTP and there should be some way to tell clients that they need to handle this.
Other Authentication systems like the ones suggested in these replies are probably better though as the requirement for authentication can be specified in the WSDL.
However you will then have to implement your own authentication system in the server.
Finally if you are going to implement your own authentication routine then I don't know what the benefits of using the SOAP header as opposed to the SOAP body to pass the credentials are, however I'm sure there is a benefit.
Thanks,
Anthony.