How to pass through credentials to PHP SOAP Request


I need to create a PHP SOAP client based on this specification:

I am able to create my soap client, and when I try to call a function it returns saying access denied:

Message: Access is denied.

Based on documentation, there is no verification/auth method that I first need to call, but it seems I have to use a type called Credentials.

struct Credentials { string Password; string Username; }

I then tried created a Credentials object:

class Credentials {
  public function __construct($username, $password) 
      $this->username = $username;
      $this->password = $password;

And assigned new values to it and used it in my SoapHeaders:

$credentials = new Credentials($username, $password);
$header = new SoapHeader('http://localhost','Credentials',$credentials,false);

When I then use a function I still get the same error:

echo "<pre>";
try {
$response = $client->__soapCall("EchoAuthenticated", array("EchoAuthenticated" => "asdfasdf"));
//catch exception
catch(Exception $e) {
  echo 'Message: ' .$e->getMessage();

Message: Access is denied.

I guess my question is that I don't know where/how to pass through the credentials in order for the API to authorise my request.

Any ideas/suggestions?


enter image description here




The authentication method should be explained in some documentation, anyway there are Soap services that use HTTP Header for authentication, for example

                'clientId' => $username,
                'clientSecret' => $password

But please consider that keys ( in my example clientId and clientSecret ) depend by the service implementation. Do you have a service documentation?

People are also looking for solutions to the problem: php - Parsing ? in htaccess


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.