Error in SOAP Request

Asked

Viewed 314 times

1

I’ve been trying to connect in a WSDL, however, unsuccessfully.

The web service provider gave me a file xxx.wsdl and passed me the credentials for the connection. I have been trying to do the following:

$client = new SoapClient('xxx.wsdl', $credentials); // Array com user e pass

Validating the available functions:

var_dump($client->__getFunctions());

Call me back:

TipoDeRetorno minhaFuncao(TipoDeDado dado); 

When I try to execute the function/method gives error:

$client->minhaFuncao(null); // Dá erro
$client->__call('minhaFuncao', [null]); // Dá erro
$client->__soapCall('minhaFuncao', [null]); // Dá erro

Returns the following error:

SoapFault in MinhaClasse.php line 80:
Server

Only the message Server as mistake. Could help me?

  • According to the manual: http://php.net/manual/en/class.soapfault.php. and also the documentation https://www.tutorialspoint.com/soap/soap_fault.htm This element is an envelope, try to give a print_r or a __toString()

  • Thank you for commenting @Khaosdoctor, in this case the message Server comes in the form of Exception, not as a wsdl message.

  • minhaFuncao() demands TipoDeDado and you’re passing null. That’s right?

  • Placed null in the example, but even if you pass an array with the required fields, it gives error!

  • Contact the WSDL provider to see if the service is actually working properly as it may be some error on the part of the SERVER.

  • To call correctly you have to pass an object instance TipoDeDado, not an array.

Show 1 more comment

1 answer

1

Assuming your code there is exactly as executed, you are passing the wrong kind of data to function, because minhaFuncao() requires a parameter of type TipoDeDado and will fail if you pass null or array or any other type.

try something like:

// Instancie primeiro um objeto do tipo TipoDeDado
$dados = new TipoDeDado($args);
$client->minhaFuncao($dados);
  • Even in this case, he keeps making the same mistake. I did exactly this way.

  • I made them like this: $client->minhaFuncao(new TipoDeDado()) and the error follows the same. I will position the supplier to see if it complements something about this error and complement here.

  • You have to check how the Object is instantiated. If it is not something of your code there must be some documentation about it. Maybe you have to pass the data of the array at the time of instantiation? Then just searching. The fact is that no other type will work if the method only accepts this.

  • 1

    Yes, I’m waiting for the vendor’s answer to see if I’m failing at something or if their wsdl is having problems.

Browser other questions tagged

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