laravel-soap icon indicating copy to clipboard operation
laravel-soap copied to clipboard

HTTP Authorization header

Open betohorta opened this issue 5 years ago • 2 comments

Hi team,

Thank you for all the work that you guys have been put into this.

Have you got any guide where you guys show how to add a custom header to a request?

I have have tried different options but unfortunately nothing seems to work.

Basically I want to add Authorization: Bearer in my header.

Would you guys please post an example on how to achieve this?

Here is my code: $nameespace = 'http://some-namespace'; $headerbody = array('Authorization' => "Bearer token"); $bearer_header = new SOAPHeader($nameespace, 'RequestorCredentials', $headerbody);

  $soapWrapper = new SoapWrapper;
  $soapWrapper->add('Inps', function ($service) use ($endpoint, $bearer_header){
  $service
    ->wsdl($endpoint)
    ->trace(true)
      ->cache(0)
      ->options(
          array('stream_context' => stream_context_create(
              array(
                  'ssl' => array(
                      'verify_peer' => false,
                      'verify_peer_name' => false
                  )
              )
          )
          )
      )
    ->classmap([
        op_tem_direito_amm::class,
        resultado::class,
    ])
    ->customHeader($bearer_header);
});

Thank you in advance.

Regards

betohorta avatar Apr 01 '20 20:04 betohorta

anyone help ?????

shinnachot avatar Dec 01 '20 10:12 shinnachot

not as yet

betohorta avatar Dec 01 '20 12:12 betohorta