Я пытаюсь разработать очень простой SOAP-сервер и клиент на PHP.Цель состоит в том, чтобы получать контент из удаленного XML-документа в качестве источника.
Это то, что я уже сделал, мне нужна помощь, как извлекать данные из файла XML вместо этого, как сейчасобычный массив.Это функция, найденная в inventory_functions.php, которая извлекает данные из массива. Как ее можно изменить для извлечения из файла XML?Я на правильном пути, это настройка SOAP?
function getItemCount($upc) {
// In reality, this data would be coming from a database
$items = array('12345'=>5,'19283'=>100,'23489'=>'234');
// Return the requested value
return $items[$upc];
}
Это код для сервера:
// Load the database
require 'inventory_functions.php';
// Turn off WSDL cache
ini_set("soap.wsdl_cache_enabled", "0");
// Create a new SoapServer object with inventory.wsdl
$server = new SoapServer("inventory.wsdl");
// Register the getItemCount function
$server->addFunction("getItemCount");
// Start the handle
$server->handle();
Это код для клиента:
// Turn off WSDL cache
ini_set("soap.wsdl_cache_enabled", "0");
// Create a new SOAPClient object
$client = new SoapClient("inventory.wsdl");
// Get the value for the function getItemCount with the ID of 12345
$getItemCount = $client->getItemCount('12345');
// Print the result
echo ($getItemCount);
Пожалуйста, помогите!