对不起,我不知道你用什么来设置你的 SOAP 服务.....
如果你能提供更多关于你的 SOAP 服务的信息(可能 Zend_Soap 给定 Zend Framework 标签)等等,那就太好了。
另外,作为一个快速的替代方案,您说您已经查看了另一台计算机上的 WSDL,或许可以在替代环境中尝试该应用程序以确保它不是环境问题。
可能是您的客户端-服务器代码的一个简单问题。
更新:好的,所以我意识到我昨天提到的示例并没有完全实现,所以我快速组合了一些东西,你可以尝试看看它是否在你的环境中工作。
代码是我发现的 here (an example of Zend_Soap_Server) 和另一个 SO 问题 here (an example of a basic SOAP service test) 的混合。
我在最后使用 ZF 1.11 对其进行了测试,我正在概述的示例使用您在新 ZF 项目中获得的默认应用程序路径(例如,模型位于目录 application/models 中,因此显示的模型是领导 Application_Model_Classname)。
如果有效,您可以进行相应调整....如果无效,我们可以尝试其他方法。
首先创建一个新的 SOAP 控制器并像这样设置类:
<?php
class SoapController extends Zend_Controller_Action
{
public function init()
{
ini_set("soap.wsdl_cache_enabled", "0"); //disable WSDL caching
$this->_helper->layout()->disableLayout(); //disable the layout
$this->_helper->viewRenderer->setNoRender(); //disable the view
}
public function indexAction ()
{
if (isset($_GET['wsdl'])) {
//return the WSDL
$this->handleWSDL();
} else {
//handle SOAP request
$this->handleSOAP();
}
}
private function handleWSDL ()
{
$strategy = new Zend_Soap_Wsdl_Strategy_AnyType();
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setComplexTypeStrategy($strategy);
$autodiscover->setClass('Application_Model_SoapService');
$autodiscover->handle();
}
private function handleSOAP ()
{
$server = new Zend_Soap_Server(null,
array('uri' => "http://YOURDOMAIN/soap?wsdl"));
$server->setClass("Application_Model_SoapService");
$server->handle();
}
public function testAction()
{
$client = new Zend_Soap_Client("http://YOURDOMAIN/soap?wsdl");
try {
echo $client->testMethod('test');
} catch (Exception $e) {
echo $e;
}
}
}
在上面的类中,WSDL 是使用 Zend_Soap_Autodiscover 自动生成的,其中一个 SoapService.php 文件位于 application/models/SoapService.php 用作模板。请注意,目标类中每个方法上方的 DocBock cmets 是此过程不可或缺的。
接下来在默认模型文件夹中创建 SoapService.php 文件:
<?php
class Application_Model_SoapService
{
/**
* testMethod
*
* @param string $string
* @return string $testSuccess
*/
public function testMethod(string $string)
{
$testSuccess = 'Test successful, the message was: ' . $string;
return $testSuccess;
}
}
如果一切正常,您可以访问:
http://YOURDOMAIN/soap?wsdl
查看 WSDL 并访问:
http://YOURDOMAIN/soap/test
使用您在 SoapController 类的 testAction() 代码中在客户端请求中指定的字符串作为消息的一部分获取成功消息。
让我知道它是否有效,我们可以从那里开始。
我可以在星期一再看看。