I have a project in front of me that requires me to create a Soap client in PHP and send a request / request for basic authorization. The WSDL client does not specify a header. This throws me off because basic authorization is used to access the API to use the web service (simple user search).
This is my code:
<?php
try {
$fullname = "Joe Smith";
$zipcode = "33149";
$session = "1a2b3c4d5e6f";
$client = new SoapClient ('example.wsdl', array ('location' => 'https://webservice/location', 'username' => "Green", 'password' => "tearocks" ) );
$search = $client-> userSearch ($ session, $fullname, $zipcode);
print $search;
} catch (SoapFault $e) {
echo $e-> faultstring;
}
?>
code>As a result, “Unauthorized request” is displayed, error 401. I went through the php.net manual and various books to no avail. Any thoughts?
source
share