Похоже, что в библиотеке NuSOAP есть небольшое упущение ... предполагается, что заголовки содержимого ДОЛЖНЫ быть «text / xml», поэтому, если ваш клиент пытается подключиться к службе, которая выводит заголовки application / soap + xml, вы: закончится ошибками, например:
Ответ не типа text / xml: application / soap + xml; charset = utf-8
Чтобы проверить это, вы можете воспользоваться следующим небольшим шаблоном функций, который я использовал для входа в службу SOAP. Помните, распечатайте клиентский объект! Вы можете не увидеть результат!
require_once('path/to/downloaded/libraries/nusoap.php');
var $endpoint = 'https://somedomain.com/path/to/soap/server/Login';
var $client; // the soapclient object
function SOAP_Login()
{
$this->client = new soapclient($this->endpoint);
$err = $this->client->getError();
if ($err)
{
// Display the error
echo '<p><b>SOAP Constructor error: ' . $err . '</b></p>';
exit;
// At this point, you know the call that follows will fail
}
$params = array(
'some' => 'thing.. depends on what the WSDL expects'
);
$result = $this->client->call('someFunction', $params);
print_r($result); // Without the fix, this prints nothing (i.e. false) !!!
print_r($this->client); // Instead, look at the state of the client object, specifically error_str and debug_str
}
Когда я распечатал свой $ result, я ничего не получил, но когда я распечатал объект $ client, я увидел, что были ошибки.
Небольшой прием, который я реализовал, был в файле nusoap.php около строки 7500. Найдите этот оператор if:
if (!strstr($headers['content-type'], 'text/xml')) {
$this->setError('Response not of type text/xml: ' . $headers['content-type']);
return false;
}
И измените его на это:
if (!strstr($headers['content-type'], 'text/xml') && !strstr($headers['content-type'], 'application/soap+xml') ) {
$this->setError('Response not of type text/xml: ' . $headers['content-type']);
return false;
}
Все это позволяет NuSOAP обрабатывать ответы, которые выдают заголовок «application / soap + xml» (который является допустимым заголовком xml).
person
Everett
schedule
16.02.2010