我使用Zend Soap Server实现了一项Web服务。
使用PHP客户端(Zend Client)连接到它,它按预期工作。然而,对于.NET客户端,它返回了相当无用的错误“未知错误”。
错误日志显示:
PHP Notice: Array to string conversion in /path/to/app/vendor/zendframework/zend-soap/Zend/Soap/Server.php on line 881
有没有人遇到过这个问题?这是我的服务器代码:
public function server()
{
// Soap Server options
$options = array(
'classmap' => array(
'TransactionType' => 'Acme\TransactionType',
),
);
// Create Soap Server
$server = new Server(public_path('file.wsdl'), $options);
// Bind Class to Soap Server
$server->setClass('Acme\Transaction');
// Handle request
$server->handle();
}
public function wsdl()
{
// Output WSDL
$autodiscover = new AutoDiscover(new ArrayOfTypeSequence());
$autodiscover->setClass('Acme\Transaction')
->setUri(\URL::route('server'))
->setServiceName('AcmeTransactions');
$wsdl = $autodiscover->generate();
$wsdl->dump(public_path('file.wsdl'));
}
Acme / Transaction看起来像这样:
class Transaction extends \Eloquent
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'transactions';
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = array();
/**
* Saves a TransactionType to the database.
*
* @param TransactionType $transaction
*
* @return bool
*/
public static function saveTransaction(TransactionType $transaction)
{
/**
* @var Transaction $model
*/
$model = new self();
$model->fill(
array(
'transaction_id' => $transaction->transaction_id,
'transaction_number' => $transaction->transaction_number,
// ...
)
);
return $model->save();
}
}
Acme / TransactionType如下所示:
class TransactionType {
/**
* @var string
*/
public $transaction_id = '';
/**
* @var string
*/
public $transaction_number = '';
// ...
}
答案 0 :(得分:0)
此问题已通过使用Zend \ Soap \ Server \ DocumentLiteralWrapper解决。
http://framework.zend.com/manual/2.2/en/modules/zend.soap.server.html#document-literal-wsdl-handling
故事的道德 - 如果您正在构建需要由C#客户端使用的Zend Soap Server,请查看document-literal-wsdl-handling以消除这些类型的跨平台问题。