首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在ZEND SOAP AutoDiscovery中设置这些复杂类型?

如何在ZEND SOAP AutoDiscovery中设置这些复杂类型?
EN

Stack Overflow用户
提问于 2011-09-28 05:40:59
回答 1查看 3K关注 0票数 5

你好,我需要写一个SOAP服务器,在那里我可以传递复杂的类型,结构看起来像这样:

代码语言:javascript
复制
<ParcelDetails>
  <countryType></countryType>
  <addressType>
    <countryType></countryType>
      .... .....
      .... ....

    <contact></contact>
  </addressType>
<ParcelDetails>

I/m使用以下代码为该服务生成WSDL文件

代码语言:javascript
复制
<?php
include_once("Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php");
include_once("Zend/Soap/Wsdl/Strategy/DefaultComplexType.php");
include_once("Zend/Soap/Wsdl/Strategy/Composite.php");
include_once("Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php");
include_once("Zend/Soap/Wsdl/Strategy/AnyType.php");
include_once('Zend/Soap/AutoDiscover.php');

include_once('Zend/Soap/Server.php');
include_once('Zend/Soap/Client.php');
include_once('Zend/Soap/Wsdl.php');

//*************************************
// Classes used by getGroup service method below 

class countryTypeSpace
{
    /** @var country */
    public $country = '';
}

class addressTypeSpace
{
    /** @var countryType */
    public $countryType = '';

    ....

    /** @var contact */
    public $contact = '';

}



class ParcelDetailsSpace
{

    /** @var countryType */
    public $countryType;

    /** @var addressType[]  */
    public $addressType;

}

//*************************************

class ServiceClass  
{
    /**
     *  ParcelDetails
     */
    public function registerParcel( $username, $pasword) {

        $group = new ParcelDetailsSpace();

        //fill in the array
        for ($i = 1; $i <= 3; $i++) {
            $countryType = new countryType();
            $countryType->country = 'country';

            $addressType = new addressTypeSpace();
            $addressType->address = 'Adresas';
            $addressType->area = 'Area';


            $group->countryType = $countryType;
            $group->addressType = $addressType;
        }

        return $group;
    }       
}


if(isset($_GET['wsdl'])) {
    $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_AnyType');
    $autodiscover->setClass('ServiceClass');
    $autodiscover->handle();
} else {
    $soap = new Zend_Soap_Server("http://localhost/zs/zserverComplex.php?wsdl");
    $soap->setClass('ServiceClass');
    $soap->handle();
}

?>

在客户端,我收到一个错误:

代码语言:javascript
复制
 Fatal error: Uncaught SoapFault exception: [VersionMismatch] Wrong
 Version in C:\Program Files
 (x86)\EasyPHP-5.3.8.0\www\zs\Zend\Soap\Client.php:1121 Stack trace:

# 0 C:\Program Files
 (x86)\EasyPHP-5.3.8.0\www\zs\Zend\Soap\Client.php(1121):
 SoapClient->__soapCall('registerParcel', Array, NULL, NULL, Array) 

# 1 C:\Program Files (x86)\EasyPHP-5.3.8.0\www\zs\zclientDpd.php(6):
 Zend_Soap_Client->__call('registerParcel', Array) 

#2 C:\Program Files
 (x86)\EasyPHP-5.3.8.0\www\zs\zclientDpd.php(6):
 Zend_Soap_Client->registerParcel(Array) 

#3 {main} thrown in C:\Program Files
(x86)\EasyPHP-5.3.8.0\www\zs\Zend\Soap\Client.php on line 1121

我尝试了不同的Zend_Soap_Wsdl_Strategy策略,你可能会在我的服务器文件顶部的includes中看到,但根本没有成功。我知道我可能遗漏了一些东西,但我不确定从哪里可以找到……

如果有人能够给我指出正确的方向,关于这些复杂的类型和自动发现,我会很高兴,至少,如果不是这个问题的正确答案的话。

因为我不能得到任何关于这个的好信息

提前谢谢你

EN

回答 1

Stack Overflow用户

发布于 2011-11-18 23:11:27

我可能超出了我的能力范围,但是我刚刚使用NuSOAP用PHP语言编写了一个web服务,它允许您定义复杂的类型并为您生成WSDL。

可能需要检查一下:http://www.scottnichol.com/nusoapintro.htm

在NuSOAP中,要创建与您提供的类型类似的复杂类型,代码应如下所示:

代码语言:javascript
复制
$server = new nusoap_server();

$server->wsdl->addComplexType(
    "addressType",
    "complexType",
    "struct",
    "all",
    "",
    array(
        "countryType" => array("name" => "countryType", "type" => "xsd:string"),
        ...
        "contact" => array("name" => "contact", "type" => "xsd:string")
    )
);

$server->wsdl->addComplexType(
    "ParcelDetails",
    "complexType",
    "struct",
    "all",
    "",
    array(
        "countryType" => array("name" => "countryType", "type" => "xsd:string"),
        "addressType" => array("name" => "addressType", "type" => "tns:addressType")
    )
);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7576016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档