Define custom parameters SoapClient PHP

3

I'm consuming an external webservice via PHP and it requests authentication in a different way, the login and password has to be passed inside the XML. But I'm not able to authenticate.

The call to the service is being created as follows.

public static function myFunction ($param){

        $soapClient = new \SoapClient('my_wsdl', [
            "trace"     => 1,
            "exception" => 0,
            'Login' => '*',
            'Senha' => '*'
        ]);

        return($soapClient->myService($param));
}

The service expects an XML as below:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="meu_endereco_api">
   <soapenv:Header>
   <Autenticacao>   
        <Login>*****</Login>
        <Password>****</Senha>
   </Autenticacao>
   </soapenv:Header>
   <soapenv:Body>
      <api:minha_api soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <meu_parametro xsi:type="xsd:string">$param</meu_parametro>
      </api:minha_api>
   </soapenv:Body>
</soapenv:Envelope>

The service returns me an authentication error:

object(stdClass)[783]
  public 'Parametro' => string 'ERRO NAO AUTENTICADO'

Does anyone have any idea how to send the authenticated request the parameters in this expected format?

    
asked by anonymous 19.08.2015 / 15:37

0 answers