cancel
Showing results for 
Search instead for 
Did you mean: 

Can't create soap header

Can't create soap header

Hi,

 

we're trying to send a soap request to the purolator shipping API. We are stuck at the header portion.

 

This is what we are sending the shipping API:

 

   // Probleme ICI

        try {
  //Define the SOAP Envelope Headers
  $headers[] = new SoapHeader ( 'http://purolator.com/pws/datatypes/v1',
                                'RequestContext',
                                array (
                                        'Version'           =>  '1.4',
                                        'Language'          =>  'en',
                                        'GroupID'           =>  'xxx',
                                        'RequestReference'  =>  'Rating Example'
                                      )
                              );
                   \Magento\Framework\App\ObjectManager::getInstance()
            ->get('Psr\Log\LoggerInterface')->debug('soapHeader created');



        } catch (\Exception $e) {
                //$debugData['result'] = ['error' => $e->getMessage(), 'code' => $e->getCode()];
                $this->_logger->critical($e);
                \Magento\Framework\App\ObjectManager::getInstance()
            ->get('Psr\Log\LoggerInterface')->debug($e);
        }

  //Apply the SOAP Header to your client
  $client->__setSoapHeaders($headers);



            \Magento\Framework\App\ObjectManager::getInstance()
            ->get('Psr\Log\LoggerInterface')->debug('soapclient2');

                return $client;


    }

It's simply not catching the error with the trap we made. What are we doing wrong?

 

Thanks!