0
Guys I’m trying to authenticate in a WS but I’m not getting it, I can connect and generate a token, but when trying to do other operations with token received I can’t fill the header and validate the session, see the section of herader:
<?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>
<Autenticacao xmlns="servidoralvo.com.br/OperacoesPortador">
<Token>string</Token>
</Autenticacao>
</soap:Header>
<soap:Body>
<CartoesPortador xmlns="servidoralvo.com.br/OperacoesPortador">
<request>
<DocumentoPortador>string</DocumentoPortador>
</request>
</CartoesPortador>
</soap:Body>
</soap:Envelope>
I’m trying the following:
$Header = '
<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>
<Autenticacao xmlns="servidoralvo.com.br/OperacoesPortador">
<Token>' . $Token . '</Token>
</Autenticacao>
</soap:Header>
</soap:Envelope>';
$AHeader = $Client->setHeaders($Header);
$AParams = array();
$AParams["request"]["DocumentoPortador"] = "14238911996";
$Conexao = $Client->Call("CartoesPortador", array($AParams), '', '', true, true);
fPrintDebug($Conexao);
It gives authentication error, but it is not the token, the error is in header construction, because this same token using native PHP Soap works.
The detail is that on the server I use on the web, there is no way to enable native Soap so I have to use Nusoap PHP
Someone would have a hint of what might be?
Marcelo Voce wants to create the wsdl directly from XML ? For the right reason using Nusoap is to use the configureWSDL method that is inside the $Soap_server object... If that’s what it is, explain to me and I’ll send you an example.
– Panda
Check it out, I did some tests with the native PHP Soap, but when I put it on the server I saw that there is no Soap, the server uses a include method, well I went to use the server method and gave some pauses because it is outdated, so not to have to be asked to the provider update the server, I’m trying to use nuSoap, I can authenticate well, but when having to use the functions that require the Token it does not validate the header... I’m not sure how to send the complete request, as I put in the xml above I have to send the header and the body, but by Soap I do not know how to do.
– Marcelo
Got it guy in Nusoap if you do not create the WSDL or XML as you are doing you create a method and records it the XML is generated by Nusoap in this case you need to put the method that creates the token and register it. Follow a CRUD I made with Nusoap, I still need to refactor but I’m sure it will help you. https://github.com/satodu/Nusoap-sample. After you register, just go to http://localhost? wsdl
– Panda
I’ll post an answer to see if it helps you
– Panda