2011-09-27 29 views
5

Xin chào Tôi cần phải viết một máy chủ SOAP, nơi tôi sẽ có thể vượt qua các loại phức tạp, structuraly rằng sẽ trông như thế này:Làm thế nào để thiết lập các loại phức tạp này trong ZEND SOAP AutoDiscovery?

<ParcelDetails> 
    <countryType></countryType> 
    <addressType> 
    <countryType></countryType> 
     .... ..... 
     .... .... 

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

và I/m sử dụng mã sau đây để tạo ra tập tin WSDL cho dịch vụ này

<?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(); 
} 

?> 

vào cuối khách hàng tôi nhận được một lỗi:

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 

I'v thử chiến lược Zend_Soap_Wsdl_Strategy khác nhau như bạn có thể thấy từ bao gồm ở đầu tệp máy chủ của tôi, nhưng không thành công ở tất cả Tôi biết rằng có thể tôi đang thiếu thứ gì đó, nhưng tôi không chắc chắn sẽ tìm ...

Tôi rất vui nếu có ai đó có thể chỉ cho tôi đi đúng hướng, về các loại phức tạp và phát hiện tự động, ít nhất, nếu không phải là câu trả lời đúng cho vấn đề này

Bởi vì tôi couldnt nhận được bất kỳ thông tin tốt về vấn đề này

Cảm ơn bạn trước

Trả lời

1

Tôi có thể ra khỏi giải đấu của mình ở đây, nhưng tôi vừa viết một dịch vụ web bằng PHP bằng NuSOAP, và nó cho phép bạn định nghĩa các kiểu phức tạp và tạo WSDL cho bạn.

Có thể là một cái gì đó để kiểm tra: http://www.scottnichol.com/nusoapintro.htm

Trong NuSOAP, để tạo ra một loại phức tạp như một trong những bạn cung cấp, mã sẽ giống như thế này:

$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") 
    ) 
); 
Các vấn đề liên quan