後在堆棧溢出4天測試和詢問的:Importing Yii Created Soap Server To Visual Studio這是結果:替代的SOAP返回數組類型
問:爲什麼我的Yii SOAP服務器不能在Visual Studio中導入?
答: Yii使用RPC編碼樣式進行WSDL,而Visual Studio需要文檔/文字。因此,您可以使用Zend Framework庫創建文檔/文字編碼的Web服務器。
新問題:經過數小時的測試後,我發現在函數中返回數組會導致Visual Studio無法導入它的錯誤。
有沒有其他的SOAP返回數組數據類型,所以Visual Studio可以導入服務器的WSDL?
而且我也無法與一個實際例子實施Yii中文檔/文字的Zend Framework創建SOAP服務器,所以我寫了我的編碼,也許別人可以參考:
。 /protected/components/soapTTS.php
<?php
class soapTTS {
/**
* @param int $CourseId
* @return array
*/
public function ListAllStudentsOnASelectiveCourse($CourseId) {
$out = helper::ListAllStudentsOnASelectiveCourse($CourseId);
return $out;
}
}
?>
在上面導致問題。
./protected/controllers/SoapController.php
<?php
class SoapController extends Controller {
public function actionService() {
Yii::import('application.vendors.*');
Yii::setPathOfAlias('Zend', Yii::getPathOfAlias('application.vendors.Zend'));
if (isset($_GET['wsdl'])) {
$autodiscover = new Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence());
$autodiscover->setBindingStyle(array('style' => 'document'));
$autodiscover->setOperationBodyStyle(array('use' => 'literal'));
$autodiscover->setClass('soapTTS');
$autodiscover->setUri('http://localhost/millms/mws/soap/service');
header("Content-type: text/xml");
echo $autodiscover->toXML();
} else {
// pointing to the current file here
$soap = new Zend\Soap\Server("http://localhost/millms/mws/soap/service?wsdl");
$soap->setObject(new Zend\Soap\Server\DocumentLiteralWrapper(new soapTTS()));
$soap->handle();
}
}
}
?>