Closed martinpfeiferdev closed 6 years ago
are you using a custom error handler? which serializer version are you using?
@goetas "jms/serializer-bundle": "^2.2"
@goetas I am not using an error handler
what about the serializer library?
@goetas I have not manipulated anything, I am using a jms library natively
@A\XmlList(skipWhenEmpty=true,entry = "Presentation\DataTransferObject\ListTest")
"entry" is not a valid name, can not contain \
can you also share your input xml?
@goetas look my xml send
<TestSend xmlns="http://www.abrasf.org.br/nfse.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="nfse.xsd">
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference>
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>XvbrFJoDCHFJ7q38XdMYngy45Kg=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>D5rBP99TUNQElWSvbc2DTHeJcq8typCZzMkzsH0A5k8Pt1ZHQOLKJB0wLyqH0FzSakxCZ/BdLUrBOQAIQrAWf0DniNJUre2GAe05q/oCgv9albG3vtAh+RWwjHkaU16V2SQOQUBYjfZOXMCtXw/MiiOLdVRzhaLKIBxO/9yCLvZuu40zd4Vr42IF2KepQF5zLIT2MW+Yz4uULkTrO3wX96Jk9bo1vGqf5jic7qZUT1TdTcr7ZfYiIeTyevnUvGGdXPBmG6kzr+CGhjgHaZBUtr7FWQ67mzDi9t23hyG+grxJ/Lndh0Bq8w/uQJlPRVLqIwTUsNYycXi4dG3sZiekCw==
</SignatureValue>
<KeyInfo>
<X509Data>
<X509SubjectName>CN=SONNER SISTEMAS DE INFORMATICA LTDA,OU=(EM BRANCO),OU=(E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hkiG9w0BAQsFAAOCAgEAPWE0nKYNfOi33eOHGtmdBSczBWNX+ujII63FpSqksw4lY4h8Z/DBO1fvivzoiWsz+SA8dn0/dEiRh/PqVZTQ/Y5Ap8KRginZ5kwqlsIK2lPvrKj5P/pz2mDcB4pS/2+tAl23C+FboAsLxgYzxu/Wu5KtUsLnXOdDWzVDegnr5hLna5EFG8qGMbFpLbfkFYIy1r9LLj0JWFyIK0h8W+A0rizy/PCH2SalFbKsZIrJfwknFWepganZFQKFAngl/zjfET1Lg6sF5cx2NYm0bQbmfDfOK1ya/t2n535eAhMXQUZyMB0DfWL0uDwBp1c2F4fgAMOw6Oi7ksFpIvjj+x7cYmZo0uonO/kKLaR76aB49FM+p61flf07IJeltmC3ty68lwX2bKWu8BLr4nOdQ6QBYeUABhaZ3ZUNEgT0KObdzXEok4SbgtKqxRLUesMgB+Jw1lW7pKS4aI4Pz3jEb3otOmvSXn9EBRDsFpOh1SwtcwxP+WMpSoVvkNeXwypvHMQPHG9J+RIEt0Q8HVJyX0RQDePqnTYAWJWycmXJxCFqpbSVKuXCx4k0CXdoD9P0ylWIayyowKDCvXt+0ThDDG/BpQkm++DY1/IbWQYMSoOuzuJK0bGDWpjfGoTzFrLYiZSVI3OWB5Wc9RQtp9tmDI33K1esSX2dS19lR3FMiStV3Ag=
</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</TestSend>
@goetas my class php...
namespace Presentation\DataTransferObject;
use Doctrine\Common\Collections\ArrayCollection;
use JMS\Serializer\Annotation as A;
use Presentation\DataTransferObject\Signature\Signature;
/**
* @A\XmlRoot("TestSend")
*/
class TestSend
{
/**
* @var ArrayCollection
* @A\Type("ArrayCollection<Presentation\DataTransferObject\ListTest>")
* @A\SkipWhenEmpty()
* @A\XmlList(skipWhenEmpty=true, inline=true, entry="child::*")
*/
private $ListTest;
/**
* @var Signature
* @A\Type("Presentation\DataTransferObject\Signature\Signature")
* @A\SkipWhenEmpty()
* @A\XmlList(skipWhenEmpty=true, entry = "Signature")
*/
private $Signature;
/**
* @return ArrayCollection
*/
public function getListTest(): ArrayCollection
{
return $this->ListTest;
}
/**
* @return Signature
*/
public function getSignature(): Signature
{
return $this->Signature;
}
}
I'm going to send the Signature class, it can only be deserialized if using XmlList.
@goetas
namespace Presentation\DataTransferObject\Signature;
use JMS\Serializer\Annotation as A;
/**
* @A\XmlNamespace(uri="http://www.w3.org/2001/XMLSchema")
* @A\XmlNamespace(uri="http://www.w3.org/2000/09/xmldsig#", prefix="ds")
*/
class Signature
{
/**
* @var SignedInfo
* @A\Type("Presentation\DataTransferObject\Signature\SignedInfo")
* @A\XmlElement(cdata=false, namespace="http://www.w3.org/2000/09/xmldsig#")
*/
private $SignedInfo;
/**
* @var string
* @A\Type("string")
* @A\XmlElement(cdata=false, namespace="http://www.w3.org/2000/09/xmldsig#")
*/
private $SignatureValue;
/**
* @var KeyInfo
* @A\Type("Presentation\DataTransferObject\Signature\KeyInfo")
* @A\XmlElement(cdata=false, namespace="http://www.w3.org/2000/09/xmldsig#")
*/
private $KeyInfo;
/**
* @return SignedInfo
*/
public function getSignedInfo(): SignedInfo
{
return $this->SignedInfo;
}
/**
* @return string
*/
public function getSignatureValue(): string
{
return $this->SignatureValue;
}
/**
* @return KeyInfo
*/
public function getKeyInfo(): KeyInfo
{
return $this->KeyInfo;
}
}
@goetas Is there a better way to show the code, or can it be right here?
@goetas Another point is that Signature, I can only deserialize if I remove the inline.
to higlight the code you can use
```php for php
```xml for xml
```js for javascript
... and so on
more info on https://help.github.com/articles/creating-and-highlighting-code-blocks/
@goetas Is there any way to deserialize an XmlList, if it is null?
@SerializedName
@XmlList
the namespace
property entry="child::*"
is not valid, please put the node name@goetas I think I was doing it the wrong way, excuse me.
The solution I managed to deserialize the Signature was like this:
@goetas Many thanks for your proactivity.
:+1:
I am trying to deserializer an arraycollection, however this attribute is optional, but the following error occurs: "Warning: JMS \ Serializer \ XmlDeserializationVisitor :: visitProperty (): Node no longer exists"
Is there any way to when it is empty, it does not deserialize?