标签: zend-soap

Zend Framework 2 SOAP AutoDiscover和复杂类型

我正在准备SOAP服务器并使用以下代码生成我的WSDL:

//(... Controller action code ...)
if (key_exists('wsdl', $params)) {
    $autodiscover = new AutoDiscover();
    $autodiscover->setClass('WebServiceClass')
                 ->setUri('http://server/webserver/uri');
    $autodiscover->handle();
} else {
    $server = new Server(null);
    $server->setUri($ws_url);
    $server->setObject($this->getServiceLocator()->get('MyController\Service\WebServiceClass'));
    $server->handle();
}

//(... Controller action code ...)
Run Code Online (Sandbox Code Playgroud)

但在我的一个WebService方法中,我有一个Array类型的参数,其中每个元素的类型为"MyOtherClass",如下所示:

    /**
     * Add list of MyOtherClass items
     *
     * @param MyOtherClass[]    $items
     *
     * @return bool
     */
    function add($items) {
        // Function code here
    }
Run Code Online (Sandbox Code Playgroud)

当我尝试生成WSDL时,我得到以下错误:

PHP Warning:  DOMDocument::loadXML(): Empty string supplied as input in /<zend framweork path>/Server/vendor/zendframework/zendframework/library/Zend/Soap/Server.php on line 734
Run Code Online (Sandbox Code Playgroud)

或者这个例外:

Cannot add a complex …
Run Code Online (Sandbox Code Playgroud)

php wsdl soapserver zend-soap zend-framework2

8
推荐指数
1
解决办法
7290
查看次数

zend soap服务器响应设置自定义ns1命名空间

我正在使用Zend_Soap_Server(WSDL模式)输出对客户端调用的xml响应.但是,我想在响应中为ns1名称空间设置自定义名称.

我注意到响应中的命名空间默认设置为:' ns1:getDoubleResponse '其中' getDouble '是被调用的服务器方法.

这是我的控制器和SOAP服务器设置:

class TestController extends Zend_Controller_Action {

    public function testAction() {

        // diable laoyouts and renderers
        $this->getHelper ( 'viewRenderer' )->setNoRender ( true );
        $server = new Zend_Soap_Server ('http://example.com/public/test/testwsdl'); 
        $server->setClass ( 'Application_Model_test');

        // register exceptions that generate SOAP faults
        $server->registerFaultException('Application_Model_soapException');

        // handle request
        $server->handle ();
    }

    public function testwsdlAction() {
        // diable laoyouts and renderers
        $this->getHelper ( 'viewRenderer' )->setNoRender ( true );      
        $wsdl = new Zend_Soap_AutoDiscover ();

        $wsdl->setClass ( 'Application_Model_test');    
        $wsdl->setUri ('http://example.com/public/test/test');

        // handle …
Run Code Online (Sandbox Code Playgroud)

php soap zend-framework soapui zend-soap

4
推荐指数
1
解决办法
3093
查看次数

nuSoap或Zend Soap?

我想知道nusoap和ZendSoap之间的区别,哪个是最好的?各有什么好处和坏处?使用这两种技术的人可以进行这种比较吗?

谢谢

php comparison nusoap zend-soap

2
推荐指数
1
解决办法
3771
查看次数

SOAP-nillable =“ true”

我正在使用Zend Framework构建Web服务。我正在使用Zend_Soap_AutoDiscover类来生成WSDL。我在此Web服务表单示例中使用了各种复杂类型:

StockItemEntity类

class StockItemEntity {
    /** @var string */
    public $sStockCode;
    /** @var string */
    public $sQty;

    public function __construct($sStockCode, $sQty){
        $this->sStockCode = $sStockCode;
        $this->sQty = $sQty;
    }   
}
Run Code Online (Sandbox Code Playgroud)

WSDL定义

<xsd:complexType name="StockItemEntity">
  <xsd:all>
    <xsd:element name="sStockCode" type="xsd:string" nillable="true"/>
    <xsd:element name="sQty" type="xsd:string" nillable="true"/>
  </xsd:all>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)

根据我在网络上的阅读了解,nillable =“ true”在那里,因为可以将任何对象的属性设置为null。因此,即使StockItemEntity对象的所有属性都设置为null,也需要nillable =“ true”来维护有效的XML文档。

我担心的是,这两个属性必须始终传递给web方法。是否可以删除“ nillable = true”以强制属性不为null?否则,有任何方法可以在这些属性中强制使用非null值。我希望避免在网络服务方面进行验证。

谢谢

亲切的问候

加布里埃尔

soap wsdl web-services zend-framework zend-soap

1
推荐指数
1
解决办法
2万
查看次数

使用wsdl自动发现的Zend Soap Server无法正常工作

这个问题重复一遍

我正在尝试使用wsdl自动发现模式中的Zend_Soap_Server创建一个Web服务,但我获得了非常奇怪的效果......这里代码:server:

<?php
require_once('Zend/Soap/AutoDiscover.php');
require_once('Zend/Soap/Server.php');
require_once('Zend/Soap/Wsdl.php');
require_once('library/SoapActions.php');
$wsdl = new Zend_Soap_Autodiscover();
$wsdl->setClass('SoapActions');
if (isset($_GET['wsdl'])) {
$wsdl->handle();
    } else {
    $server = new Zend_Soap_Server('http://localhost:8083/server.php?wsdl');
    $server->setClass('SoapActions');
    $server->setEncoding('ISO-8859-1');
    $server->handle();
    }
Run Code Online (Sandbox Code Playgroud)

SoapActions类:

class SoapActions {

/**
 * Test function
 * 
 * @param String $a
 * @param String $b
 * @return String
 */
 public function test1($a, $b) {
    return "you passed me ".$a." ".$b;
 }

 /**
 * Test function 2
 * 
 * @param String $a
 * @param String $b
 * @return String
 */
 public …
Run Code Online (Sandbox Code Playgroud)

soap wsdl zend-framework zend-soap

1
推荐指数
1
解决办法
5651
查看次数