How to send parameters by Soap header and join parameters to body

Asked

Viewed 588 times

0

I’m wondering how I send the header of a Soap and add the parameter that goes to the body. I’m putting the code I already did and Soap:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Seguranca xmlns="http://satussistemas.org/">
  <Usuario>string</Usuario>
  <Senha>string</Senha>
</Seguranca>
</soap:Header>
<soap:Body>
<pegaArquivoAutomacao xmlns="http://satussistemas.org/">
  <nomeArquivo>string</nomeArquivo>
</pegaArquivoAutomacao>
</soap:Body>
</soap:Envelope>

And here’s the code:

$client = new SoapClient('Meu WSDL',array());

$auth = array('Seguranca'=>array('Usuario'=>'usuario', 
                                         'Senha'=>'senha')); 

$header = new SoapHeader('pegaArquivoAutomacao','Seguranca',$auth,true);

try{
   $resultProduto = $client->__setSoapHeaders($header);
   print_r($resultProduto);
}
   catch (SoapFault $exceptionProduto) {
   echo $exceptionProduto;      
}
  • http://answall.com/questions/98094/capturar-header-do-soap-com-php

  • Thank you very much for the help, but even so the return value is coming empty, even though I know that the webservice is working perfectly. You know what it can be?

  • Try this way, I always use this way to add the Header to Request http://www.php.net/manual/en/soapclient.setsoapheaders.php#93460

  • Thank you very much for your answers. I just learned that the server is not letting me get the binary file, now that they have released the file is all working normally.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.