Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Apress.Pro.Drupal.7.Development.3rd.Edition.Dec.2010.pdf
Скачиваний:
74
Добавлен:
14.03.2016
Размер:
13 Мб
Скачать
☆

CHAPTER 20 ■ XML-RPC

This will result in the following message being displayed:

Could not get state name because the remote site gave an error: Not Found (404).

Call Syntax Errors

Here’s what is returned if you can successfully reach the server but try to get a state name from betty.userland.com without giving the state number, which is a required parameter:

$state_name = xmlrpc('http://betty.userland.com/RPC2', array('examples.getStateName'));

The remote server returns the following:

<?xml version="1.0"?> <methodResponse>

<fault>

<value>

<struct>

<member>

<name>faultCode</name>

<value>

<int>7</int>

</value>

</member>

<member>

<name>faultString</name>

<value>

<string>Can't evaluate because the name “0” hasn’t been defined.</string> </value>

</member>

</struct>

</value>

</fault>

</methodResponse>

The server was up and our communication with it is fine; the preceding code is returned with an HTTP response code of 200 OK. The error is identified by a fault code and a string describing the error in the XML response. Your error-handling code would be the same:

$state_name = xmlrpc('http://betty.userland.com/RPC2', array('examples.getStateName'));

if ($error = xmlrpc_error()) { if ($error->code <= 0) {

$error->message = t('Outgoing HTTP request failed because the socket could not be opened.');

}

456

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]