你好,我需要写一个SOAP服务器,在那里我可以传递复杂的类型,结构看起来像这样:
<ParcelDetails>
<countryType></countryType>
<addressType>
<countryType></countryType>
.... .....
.... ....
<contact></contact>
</addressType>
<ParcelDetails>I/m使用以下代码为该服务生成WSDL文件
<?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();
}
?>在客户端,我收到一个错误:
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中看到,但根本没有成功。我知道我可能遗漏了一些东西,但我不确定从哪里可以找到……
如果有人能够给我指出正确的方向,关于这些复杂的类型和自动发现,我会很高兴,至少,如果不是这个问题的正确答案的话。
因为我不能得到任何关于这个的好信息
提前谢谢你
发布于 2011-11-18 23:11:27
我可能超出了我的能力范围,但是我刚刚使用NuSOAP用PHP语言编写了一个web服务,它允许您定义复杂的类型并为您生成WSDL。
可能需要检查一下:http://www.scottnichol.com/nusoapintro.htm
在NuSOAP中,要创建与您提供的类型类似的复杂类型,代码应如下所示:
$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")
)
);https://stackoverflow.com/questions/7576016
复制相似问题