Search code examples
c#phpsoap-clientsoapheader

C# web service code equivalent in php (sending auth data as header)


We are trying to use a web service (SoapClient) in a PHP project to send SMS. The web service is created with C# (dot net framework). The project manager described that the authentication data have to be sent using headers not as arguments in method (like most web services).

Here is the sample code they gave us:

using (var sms = new sms.Service()) 
{
    var auth = new sms.AuthHeader();

    auth.Username = "SERVICE_USERNAME";
    auth.Password = "SERVICE_PASSWORD";
    sms.AuthHeaderValue = auth;

    return sms.SendSms(messagesArray, phoneNumbersArray);            
}

The web service address is:

http://192.168.10.10/Service.asmx?WSDL

I would appreciate if anyone can suggest an equivalent for this code in PHP?


Solution

  • http://php.net/manual/de/class.soapheader.php

    SoapHeader {
    /* Methoden */
        __construct ( string $namespace , string $name [, mixed $data [, bool $mustunderstand [, string $actor ]]] )
        SoapHeader ( string $namespace , string $name [, mixed $data [, bool $mustunderstand = FALSE [, string $actor ]]] )
    }
    

    Here is an example too: How to set this php soap header?