誰でも私の問題を解決できますか? Web サービスからデータを取得しようとしていますが、サーバーの応答が無効な XML である場合があります。データサイズに依存することに気付きました。応答が特定のサイズに達すると、</SOAP-ENV:Envelop
代わりにで終了します</SOAP-ENV:Envelope>
。
これが私のコード例です: 1 つのコントローラー内のクライアントとサーバー。メソッド "success" は正常に機能しますが、同様のメソッド "fail" は機能しません。さらに: nginx および php-fpm の場合、「success」メソッドも失敗します (php_mod を使用した apache の場合、「success」メソッドが機能します)。
<?php
class SoapController extends CController
{
public function actions()
{
return array('wsdl' => array('class' => 'CWebServiceAction'));
}
private function getData($size)
{
return array_fill(0, $size, '18ad96e6-5526-11e0-9c19-00248c654095');
}
/**
* @return array
* @soap
*/
public function success()
{
return $this->getData(104);
}
/**
* @return array
* @soap
*/
public function fail()
{
return $this->getData(105);
}
public function actionTest()
{
$client = new SoapClient($this->createAbsoluteUrl('wsdl'), array('trace' => true));
$methods = array('success', 'fail');
foreach ($methods as $method) {
try {
$result = call_user_func(array($client, $method));
$result = count($result);
} catch (SoapFault $ex) {
$result = $ex->getMessage();
}
echo $method . ' result: ' . $result . '<br>';
echo $method . ' response: <br>' . htmlspecialchars($client->__getLastResponse()) . '<br><br>';
}
}
}
ソフトウェアのバージョン:
- Ubuntu サーバー 12.10
- Yii 1.1.13
- PHP5.4.6
- アパッチ 2.2.22
- ニンクス 1.2.1