Webservice returns pro SoapUI, but does not return pro PHP

5

I am consuming a WebService SOAP and I am encountering the following problem: The WebService has two functions. In PHP, using the SoapClient class, I created the client and consumed the first function without problem. But when I try to use the second function, it returns a lot of errors with no connection. But when I try to consume this second function using SoapUI, the second function sends the return correctly. My question is: can it be error in WebService? But if so, how can SoapUI consume the same?

Complementing, I have a certain mistrust that the error might even be in the WebService, because when I tried to import the WSDL from it in Java or Python, the import failed. And this has never happened to other web-services I've already consumed. The path of the WebService is: link

My PHP code:

<?php

    $clientesoap = new SoapClient("http://wscaixa.datasysonline.net/wsDadosCaixa.asmx?wsdl", array(
        'cache_wsdl' => WSDL_CACHE_NONE
    ));

    $xml = "<cartoes>";
    $xml .= "<lancamento>";
    $xml .= "<pedido>XXXX-XXXXX</pedido>";
    $xml .= "<parcela>1</parcela>";
    $xml .= "<nsu>666666</nsu>";
    $xml .= "<valorParcela>36</valorParcela>";
    $xml .= "<valorLiquido>35</valorLiquido>";
    $xml .= "<dtVencimento>10/03/2015</dtVencimento>";
    $xml .= "<dtAntecipacao>12/03/2015</dtAntecipacao>";
    $xml .= "<dtLiquidacao>12/03/2015</dtLiquidacao>";
    $xml .= "<taxaAntecipacao>2</taxaAntecipacao>";
    $xml .= "</lancamento>";
    $xml .= "</cartoes>";  

    $param = new stdClass();
    $param->Token = 'xxxxxxxxxxxxxxxxxxxxxxx';
    $param->Xml = $xml;

    $resultado = $clientesoap->AtualizarConciliacao($param);

    // a funcao abaixo funciona, mas a de cima (AtualizarConciliacao) dá erro:
    // $param->Data '2016-03-03';
    // $resultado = $clientesoap->BaixarVendasCartao($param);


    print_r($resultado);

?>
    
asked by anonymous 24.03.2016 / 13:05

1 answer

0

Hello, Paul.

I took the liberty of transporting your code to visual studio and I was able to identify the problem.

The error displayed indicates that the token would be null, and that's it. If you look at the sent parameters, you will see that you only pass the XML and not the token as the method definition is. Even passing it, I got the same error message if you send a token in string format. To work correctly you need to convert the token to base64 string.

In C #, the conversion of your token would look like this:

var encoding = System.Text.Encoding.UTF8;
byte[] textAsBytes = encoding.GetBytes(token);
string base64String = System.Convert.ToBase64String(textAsBytes);

So when you call, you call: client.UpgradeConciliation (base64String, docxml);

The error message will occur, but will now be indicating "Invalid Token.", which is a standard webservice message in token validation.

From what I read in the PHP documentation , the command for you would be:

(...)   
$tokenBase64 = base64_encode($token);
$resultado = $clientesoap->AtualizarConciliacao($tokenBase64, $xml);

Hope it helps. Abs

    
24.03.2016 / 16:51