2016-04-02 8 views
1
Ben bir SOAP sunucusu oluşturmak için BeSimple SoapBundle kullanıyorum ama aşağıdaki kod parçası ile sorun yaşıyorum

:BeSimple SoapBundle - Açıklamalar: Karmaşık türlerinde dairesel başvurular işleme

namespace AppBundle\Entity; 

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; 

/** 
* @Soap\Alias("Item") 
*/ 
class Item 
{ 

    /** 
    * @Soap\ComplexType("AppBundle\Entity\Item[]") 
    */ 
    protected $items; 

    /** 
    * @Soap\ComplexType("string") 
    */ 
    protected $name; 

i gerekenler get komplekstype öğelerinin bir ağacıdır, ancak ek açıklama @Soap \ ComplexType ("AppBundle \ Entity \ Item []") kullanıldığında dairesel bir başvuru hatası alıyorum.

Bu durumla nasıl başa çıkabilirim?

cevap

0

Sonunda bu sorun için bir çözüm buldum. Bence gerekli olmamalı ama bulduğum en iyi ve tek yol.


namespace AppBundle\Entity; 

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; 

class Item 
{ 

    /** 
    * @Soap\ComplexType("string") 
    */ 
    protected $name; 

Kontrolör kullanım örneği

namespace AppBundle\Entity; 

use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; 

/** 
* @Soap\Alias("ComplexItem") 
*/ 
class ComplexItem extends Item 
{   
    /** 
    * @Soap\ComplexType("AppBundle\Entity\Item") 
    */ 
    protected $item; 

    public function setItem($item) 
    { 
     $this->item = $item; 
    } 
:
/** 
* @Soap\Method("getItem") 
* @Soap\Result(phpType = "AppBundle\Entity\ComplexItem") 
*/ 
public function getItem() 
{ 
    $item = new ComplexItem(); 
    $complexItem = new ComplexItem(); 
    $complexItem->setItem($item); 

    return $complexItem; 
} 

Birini yardımcı olur. Bunu çözmenin daha iyi bir yolunu biliyorsanız, lütfen bildirin.