R
R
ragnar_ok2019-08-23 22:37:45
PHP
ragnar_ok, 2019-08-23 22:37:45

How to implement request using PHP SoapClient?

// Получаю экземпляр SoapClient
$url = "";
$client = new SoapClient($url, ["trace" => 1, "exception" => 0]); 
// Получаю список доступных SOAP-функций
$client->__getFunctions();

SoapClient::__getFunctions returns the following:
array(2) {
  [0]=>
  string(44) "GetDataResponse GetData(GetData $parameters)"
  [1]=>
  string(44) "GetDataResponse GetData(GetData $parameters)"
}

Further:
// Вызываю SOAP-функцию
$client->GetData($parameters);
// Возвращаю SOAP-ответ
$client->__getLastResponse();

The SOAP response comes as an embedded XML document. That is it is necessary to parse XML contents __last_response? Am I doing it right?
If I don't specify when getting the SoapClient instance $options = ['trace' => 1, 'exception' => 0], I don't get the __last_response. Instead, I get the following. Why?
object(SoapClient)#82 (5) {
  ["_soap_version"]=>
  int(1)
  ["sdl"]=>
  resource(5) of type (SOAP SDL)
  ["httpsocket"]=>
  resource(6) of type (stream)
  ["_use_proxy"]=>
  int(0)
  ["httpurl"]=>
  resource(7) of type (SOAP URL)
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Vasilkov, 2019-08-23
@ragnar_ok

If the request is not HTTPS, I recommend installing the WireShark program and trying to see what other requests are. Then you can compose a request in the form of text and send it. And only then figure out how to hang the code on it all, which is sewn in puff under the word Soap.
Because there is so much hell in this standard that simplifies life that it would be better if it didn’t exist.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question