Answer the question
In order to leave comments, you need to log in
How to implement a SOAP request in PHP?
Good afternoon.
I didn’t work closely with SOAP on PHP, so I decided to turn here for advice.
Task. Implement tour search via SOAP request.
Description here - https://www.natalie-tours.ru/webservices_RU/
Compose "one level" of the hierarchy seems to understand how.
That is, for example, the code
<?php
$req_pms = new stdClass();
$req_pms->wsLoginPassword = new stdClass();
$req_pms->wsLoginPassword->wslogin = "MY_LOGIN";
$req_pms->wsLoginPassword->wspassword = "MY_PASSWORD";
$req_data = new SoapVar($req_pms, SOAP_ENC_OBJECT, 'wsLoginPassword', ' www.natalie-tours.ru/webservices ');
$client = new SoapClient(' www.natalie-tours.');
echo '';
print_r($client->getAllAgeTypes($req_data));
?>
All clear. All clear.
And how to implement, for example, the addTourproduct request?
That is, there are different namespaces. Nesting, etc.
That is, you can’t write like that anymore.
$req_pms = new stdClass();
$req_pms->wsLoginPassword = new stdClass();
$req_pms->wsLoginPassword->wslogin = "MY_LOGIN";
$req_pms->wsLoginPassword->wspassword = "MY_PASSWORD";
$req_pms->addToOrderRequest = new stdClass();
$req_pms->addToOrderRequest->orderId = 123;
Thanks in advance for any help.
Answer the question
In order to leave comments, you need to log in
why did you go this way and not like this:
ini_set('soap.wsdl_cache_enabled', '0');
ini_set('soap.wsdl_cache_ttl', '0');
try {
// Создание SOAP-клиента
$client = new SoapClient("http://www.natalie-tours.ru/webservice/BookingWS?WSDL");
$params = array(
'wsLoginPassword' => array(
'wslogin' => "MY_LOGIN",
'wspassword' => "MY_PASSWORD"
));
$request = $client->getAllAgeTypes($params);
$result = $request->getAllAgeTypes->result;
echo "$result";
}
catch (SoapFault $exception)
{
echo $exception->getMessage();
}
And how to implement, for example, the addTourproduct request?
That is, there are different namespaces. Nesting, etc.
That is, you can’t write like that anymore.
$req = new Request();
$req->messageList = new MessageList();
$req->messageList->message = new Message();
$req->messageList->message->phone = '79871234567';
$req->messageList->message->text = 'Тестовое сообщение 1';
$req->messageList->message->date = '2013-07-21T15:00:00.26';
$req->messageList->message->type = 15;
$client = new SoapClient( "http://{$_SERVER['HTTP_HOST']}/smsservice.wsdl.php",
array( 'soap_version' => SOAP_1_2));
var_dump($client->sendSms($req));
Good afternoon! Did you manage to implement the SOAP request? Could you show a working example, if it's easy, because it doesn't work for my locale. Thank you!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question