You need to authenticate your SOAP requests using HTTP Basic Authentication.
Pass a username and password in via the options array by setting the login and password keys:
$options = array('login' => 'elvis', 'password' => 'the-king'); $client = new SOAPClient('http://www.example.com/service.wsdl', $options);
There are a number of ways to handle authentication within SOAP requests. A few popular ways are HTTP Basic Authentication, placing data inside the SOAP header, and using the WS-* specifications, including WS-Security.
To make ext/soap add HTTP Basic Authentication credentials to every request, pass your username and password in as options when you create the SOAP client:
<?php $options = array('login' => 'elvis', 'password' => 'the-king'); $client = new SOAPClient('http://www.example.com/service.wsdl', $options); ?>
Now every request will have an additional HTTP header of Authorization.
If your service requires data set in the SOAP request header, see Recipe 26.1 for details on handling that.
As of this writing, you cannot use any XML Security specifications with ext/soap. However, Rob Richards is working on it. For more information, check out http://www.cdatazone.org/index.php?/archives/9-WSSE-and-extsoap.html.
14.8.4. See Also
Recipe 15.8 for handling SOAP authentication in a SOAP server.