BeSimple / BeSimpleSoapBundle

NOT MAINTAINED - [READ-ONLY] Subtree split of the BeSimpleSoap -- clone into BeSimple/SoapBundle/ (master at BeSimple/BeSimpleSoap). Please submit issues on BeSimple/BeSimpleSoap repository.
http://besim.pl/SoapBundle/
61 stars 67 forks source link

Embedded documents loading #25

Open feufy78 opened 12 years ago

feufy78 commented 12 years ago

Hi, I'm using Doctrine ODM with mongoDB. This webservice will manage users and their resumes. I've successfully created a soap webservice to do some basic operations on simple documents. However I've have a problem when it comes to work with embedded documents.

Each time I try to load a document without the embedded document (A user without any attached resume), an error is thrown: request.CRITICAL: ErrorException: Warning: spl_object_hash() expects parameter 1 to be object, null given in /var/www/Symfony/vendor/bundles/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php line 66 (uncaught exception) at /var/www/Symfony/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php line 65 [] []

If I try to load a document with the embedded document (A user with an attched resume) the the service works fine and return a User object with a Resume Object inside it.

In my user class I've set the resume property (as embedded document in mongodb) to nillable, but no effect on this bug. /* * @MongoDB\EmbedOne(targetDocument="Resume") * @Soap\ComplexType("Sem\CvtBundle\Document\Resume", nillable=true) * / private $resume;

If I try with the "regular" symfony2 app, the problem wont occur and will load users even if they don't have a resume attached.

Thx in advance for your help.

getme commented 12 years ago

yes it's a problem, "nillable" for basic types is supported, but no support for objects(?)

christiankerl commented 12 years ago

adding a

if(null === $message)
{
  return null;
}

before the following line:

https://github.com/BeSimple/BeSimpleSoapBundle/blob/master/ServiceBinding/RpcLiteralResponseMessageBinder.php#L63

should fix the problem, can you try this?

feufy78 commented 12 years ago

Hi, you're the boss!! Problem fixed!

Thanks a lot for your help!

christiankerl commented 12 years ago

I reopen it because, it hasn't been fixed in the code base yet :)

@francisbesset why is checkComplexType(...) there? is it only to verify that all type and nillable=false constraints are enforced? If this is the case we might think about removing it or providing an option to disable it, because reflection and object graph traversal might result in bad performance. Besides it's in the direction server->client so we don't risk getting invalid or malicous data in...

feufy78 commented 12 years ago

Hi guys,

Just to let you know I had to modify the RpcLiteralRequestMessageBinder.php too. Same lines were add to the checkComplexType function...