Zend_Soap_AutoDiscover没有';t生成wsdl文件


Zend_Soap_AutoDiscover doesn't generate wsdl file

Zend_Soap_AutoDiscover类生成WSDL文件时遇到问题
有人能解释一下我做错了什么吗?

在bootstrap.php中,我有一个方法:

public function _initWsdl()
{
    require_once("http://localhost:8080/zf_mta/backend.php");
    $autoDiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
    $autoDiscover->setClass('Backend');
    $autoDiscover->setUri('http://localhost:8080/zf_mta/backend.php');
    $autoDiscover->handle();
    return $autoDiscover;
}

这是backend.php类

class Order {
    /** @var string */
    public $productid;
    /** @var string */
    public $customerid;
    /** @var int */
    public $productcnt;
    public function __construct($productid,$customerid,$productcnt) {
        $this->productid  = $productid;
        $this->customerid = $customerid;
        $this->productcnt = $productcnt;
    }
}
class Orders {
    /** @var Order[] */
    public $orders;
}
class Backend {
    /**
     * @param Orders $orders
     * @return string
     */
    public function placeOrders($orders) {
        return print_r($orders,1);
    }

}

我收到错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。。。

error_log:

[07-Sep-2012 13:39:48 UTC] PHP Warning:  require_once() [<a href='function.require-once'>function.require-once</a>]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in E:'Zend Server'Apache2'htdocs'zf_mta'application'Bootstrap.php on line 18
[07-Sep-2012 13:39:48 UTC] PHP Warning:  require_once(http://localhost:8080/zf_mta/backend.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: no suitable wrapper could be found in E:'Zend Server'Apache2'htdocs'zf_mta'application'Bootstrap.php on line 18
[07-Sep-2012 13:39:48 UTC] PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'http://localhost:8080/zf_mta/backend.php' (include_path='E:'Zend Server'Apache2'htdocs'zf_mta'application/../library;E:'Zend Server'Apache2'htdocs'zf_mta'library;.;E:'Zend Server'ZendServer'share'ZendFramework'library') in E:'Zend Server'Apache2'htdocs'zf_mta'application'Bootstrap.php on line 18

Florent的评论解决了第一个问题:PHP配置禁止使用HTTP包含文件。因此,您需要更改require语句以引用文件系统中的文件名。

然而,我看到你的代码还有其他几个问题:

  • 您正在将生成的WSDL的URI设置为后端类的URI。这是行不通的,因为该文件不包含充当SOAP客户端或SOAP服务器所需的代码。

  • Zend_Soap_Autodiscover通常在SOAP服务器中用于响应客户端对WSDL副本的请求。因此,您通常会将该代码包含在专门用于处理该请求的方法中,而不是应用程序引导程序中。

  • 忽略前面的一点,我还注意到您在_initWsdl()函数的末尾返回了Zend_Soap_Autodiscover实例。我敢肯定,调用_init...()方法的代码忽略了从这些方法返回的任何值或对象,所以最终这段代码将不起任何作用。

我认为您需要查看一些示例代码,才能真正了解如何使用Zend Framework实现SOAP服务器。以下片段是关于将Zend Framework用于SOAP服务的最简单示例,我可以想出这个示例:http://pastebin.com/9mb64LeG请注意,它不使用Zend MVC或路由基础设施,但它可能会帮助您了解Zend_Soap_ServerZend_Soap_Autodiscover的基本用法。