Closed h3llr4iser closed 7 years ago
are you sure? see https://github.com/schmittjoh/serializer/pull/724
Can you tell me how is your root xml node? are you using namespaces?
If I go back to jms/serializer 1.4.2 and jms/serializer-bundle 1.1.0 works.
namespace AppBundle\Entity\WebService;
/**
* @ORM\Entity
* @ORM\Table(name="gt_auth_request")
* @XmlRoot("AuthRequest")
*/
class GtAuthRequest
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Exclude()
*/
private $id;
/**
* @ORM\Column(type="string", nullable=true)
* @JMS\SerializedName("action")
* @JMS\XmlElement(false)
*/
private $action;
/**
* @ORM\Column(type="string", nullable=true)
* @JMS\SerializedName("license")
* @JMS\XmlElement(false)
*/
private $license;
/**
* @ORM\Column(type="string", nullable=true)
* @JMS\SerializedName("vin")
* @JMS\XmlElement(false)
*/
private $vin;
/**
* @ORM\OneToOne(
* targetEntity="AppBundle\Entity\WebService\GtInterventionType",
* mappedBy="gtAuthRequest",
* cascade={"persist","remove"}
* )
* @JMS\Type("AppBundle\Entity\WebService\GtInterventionType")
* @JMS\SerializedName("interventionType")
*/
private $gtInterventionType;
/**
* @ORM\OneToOne(
* targetEntity="AppBundle\Entity\WebService\GtHeader",
* mappedBy="gtAuthRequest",
* cascade={"persist","remove"}
* )
* @JMS\Type("AppBundle\Entity\WebService\GtHeader")
* @JMS\Accessor(setter="setGtHeader")
* @JMS\SerializedName("header")
*/
private $gtHeader;
/**
* @ORM\OneToOne(
* targetEntity="AppBundle\Entity\WebService\GtAuthResponse",
* mappedBy="gtAuthRequest",
* cascade={"persist","remove"}
* )
*/
private $gtAuthResponse;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\WebService\GtLine",
* mappedBy="gtAuthRequest",
* cascade={"remove","persist"}
* )
* @JMS\SerializedName("lines")
* @JMS\Type("ArrayCollection<AppBundle\Entity\WebService\GtLine>")
* @JMS\XmlList(inline = false, entry = "line")
*/
private $gtLines;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\WebService\GtTyreChange",
* mappedBy="gtAuthRequest",
* cascade={"persist","remove"}
* )
* @JMS\SerializedName("tyreChangeList")
* @JMS\Type("array<AppBundle\Entity\WebService\GtTyreChange>")
* @JMS\XmlList(inline = false, entry = "tyreChange")
*/
private $gtTyresChange;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\WebService\GtComm",
* mappedBy="gtAuthRequest",
* cascade={"persist","remove"}
* )
* @JMS\SerializedName("commList")
* @JMS\Type("array<AppBundle\Entity\WebService\GtComm>")
* @JMS\XmlList(inline = false, entry = "communication")
*/
private $gtComms;
/**
* @ORM\OneToMany(
* targetEntity="AppBundle\Entity\WebService\GtNote",
* mappedBy="gtAuthRequest",
* cascade={"persist","remove"}
* )
* @JMS\SerializedName("noteList")
* @JMS\Type("array<AppBundle\Entity\WebService\GtNote>")
* @JMS\XmlList(inline = false, entry = "note")
*/
private $gtNotes;
}
namespace AppBundle\Entity\WebService;
use Doctrine\ORM\Mapping AS ORM;
use JMS\Serializer\Annotation as JMS;
/**
* @ORM\Entity
* @ORM\Table(name="gt_line")
*/
class GtLine
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Exclude()
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=true)
* @JMS\SerializedName("type")
* @JMS\XmlElement(false)
*/
private $type;
/**
* @ORM\Column(type="string", nullable=true)
* @JMS\SerializedName("code")
* @JMS\XmlElement(false)
*/
private $code;
}
<?xml version="1.0" encoding="utf-16"?>
<AuthRequest>
<action>U</action>
<interventionType>
<id>2</id>
</interventionType>
<license>xxxxxxxxxxxxxx</license>
<vin>xxxxxxxxxxxxxxxxx</vin>
<header>
<authorizationID>xxxxxxxxx</authorizationID>
<entityCode>xxxxxxxxxxx</entityCode>
<status>A</status>
<expedientNo>000210</expedientNo>
<authorizationNumber/>
<vehicleEntryDate>2017-03-10T07:00:00</vehicleEntryDate>
<license>xxxxxxxxxx</license>
<repairShop>
<entityCode>741852963</entityCode>
<name>xxxxxxxxxxxxxxxx</name>
<taxCode/>
<observation/>
</repairShop>
<driver>
<description/>
<name>xxxxxxxxxxxx</name>
<contactPhone>xxxxxxxxxxxxxxxx</contactPhone>
</driver>
<observation/>
<user>
<code/>
<name>xxxxxxxxxxxxxx</name>
</user>
<userRole>
<code>INTERNAL</code>
<name>SUPERUSER</name>
</userRole>
<invoice>
<issued>false</issued>
<electronicInvoice>false</electronicInvoice>
<noReplacedTyres>0</noReplacedTyres>
<totalBaseAmount>323.07</totalBaseAmount>
<totalDiscountAmount>64.61</totalDiscountAmount>
<totalAmountIncDisc>258.46</totalAmountIncDisc>
<taxValue>21.00</taxValue>
<totalTaxAmount>54.28</totalTaxAmount>
<totalFinalAmount>312.74</totalFinalAmount>
</invoice>
<orderNo/>
<expectedRepairEndDate>2017-03-10T07:00:00</expectedRepairEndDate>
<actualVehicleKM>345</actualVehicleKM>
<extension>false</extension>
<axleList/>
<tyreDOTList/>
<tyreRunflat>false</tyreRunflat>
<failedRulesNumber>0</failedRulesNumber>
<paintSystem>5</paintSystem>
</header>
<lines>
<line>
<type>1</type>
<code>8671018402</code>
<description>Filtro antipolen - MOTRIO - Nueva</description>
<productCode>65900</productCode>
<quantity>1.00</quantity>
<unitPrice>21.35</unitPrice>
<baseAmount>21.35</baseAmount>
<discountAmount>6.40</discountAmount>
<totalAmount>14.95</totalAmount>
<partCodeList>
<partCode>65900</partCode>
</partCodeList>
<actionList>
<action>
<id>1</id>
<description>Sustituir</description>
</action>
</actionList>
</line>
<line>
<type>1</type>
<code>110265505R</code>
<description>Arandela tapón cárter aceite</description>
<productCode>06070</productCode>
<quantity>1.00</quantity>
<unitPrice>2.04</unitPrice>
<baseAmount>2.04</baseAmount>
<discountAmount>0.61</discountAmount>
<totalAmount>1.43</totalAmount>
<partCodeList>
<partCode>06070</partCode>
</partCodeList>
<actionList>
<action>
<id>1</id>
<description>Sustituir</description>
</action>
</actionList>
</line>
<line>
<type>1</type>
<code>8671002274</code>
<description>Filtro aceite - MOTRIO - Nueva</description>
<productCode>06100</productCode>
<quantity>1.00</quantity>
<unitPrice>9.49</unitPrice>
<baseAmount>9.49</baseAmount>
<discountAmount>2.85</discountAmount>
<totalAmount>6.64</totalAmount>
<partCodeList>
<partCode>06100</partCode>
</partCodeList>
<actionList>
<action>
<id>1</id>
<description>Sustituir</description>
</action>
</actionList>
</line>
<line>
<type>1</type>
<code>RP141J55/5</code>
<description>Aceite motor - 05W40 REPSOL - Nueva</description>
<productCode>G0600</productCode>
<quantity>4.80</quantity>
<unitPrice>10.95</unitPrice>
<baseAmount>52.56</baseAmount>
<discountAmount>10.51</discountAmount>
<totalAmount>42.05</totalAmount>
<partCodeList>
<partCode>G0600</partCode>
</partCodeList>
<actionList>
<action>
<id>1</id>
<description>Sustituir</description>
</action>
</actionList>
</line>
<line>
<type>1</type>
<code>727122052R</code>
<description>Luna parabrisas</description>
<productCode>85010</productCode>
<quantity>1.00</quantity>
<unitPrice>140.00</unitPrice>
<baseAmount>140.00</baseAmount>
<discountAmount>14.00</discountAmount>
<totalAmount>126.00</totalAmount>
<partCodeList>
<partCode>85010</partCode>
</partCodeList>
<actionList>
<action>
<id>1</id>
<description>Sustituir</description>
</action>
</actionList>
</line>
</lines>
<tyreChangeList/>
<commList/>
<noteList/>
</AuthRequest>
GtAuthRequest {#4030 ▼
-id: null
-action: "U"
-license: "xxxxxxxx"
-vin: "xxxxxxxxxxxx"
-gtInterventionType: GtInterventionType {#4054 ▶}
-gtHeader: GtHeader {#4192 ▼
-id: null
-authorizationID: "523384"
-entityCode: "xxxxxxxxxxx"
-status: "A"
-expedientNo: "000210"
-authorizationNumber: null
-authorizationDate: null
-vehicleEntryDate: DateTime {#4202 ▶}
-license: "xxxxxxxxxx"
-observation: ""
-operationDate: null
-orderNo: ""
-orderDate: null
-occurrenceDate: null
-expectedRepairEndDate: DateTime {#4204 ▶}
-repairEndDate: null
-vehicleExitDate: null
-contactPhone: null
-actualVehicleKM: 345
-amountRequested: null
-extension: false
-axleType: null
-tyreRunflat: false
-report: null
-failedRulesNumber: 0
-gtAuthRequest: null
-gtUser: GtUser {#4224 ▶}
-gtUserRole: GtUserRole {#4246 ▶}
-gtDriver: GtDriver {#4276 ▶}
-gtRepairShop: GtRepairShop {#4310 ▶}
-gtInvoice: GtInvoice {#4368 ▶}
-gtAxleList: []
-gtTyreDOTList: []
}
-gtAuthResponse: null
-gtLines: ArrayCollection {#4372 ▼
-elements: []
}
-gtTyresChange: []
-gtComms: []
-gtNotes: []
}
which php version are you using?
PHP 5.6.25
https://github.com/schmittjoh/serializer/pull/697 might have changed the behavior of the deserializer, but i'm not able to reproduce the error you are reporting...
do you have some other layers before the deserialization process starts? is the XML you posted complete? is this a unit test?
unless you find a way to isolate the failure, it will be hard for me to help you and will have to close the ticket as "can not reproduce"... :cry:
I have found the problem: "<AuthRequest xmlns="http://www.xxxxxx.xx>" If I quit "xmlns="http://www.xxxxxx.xx" works.
<?xml version="1.0" encoding="utf-16"?>
<AuthRequest xmlns="http://www.xxxxxx.xx>
<lines>
<line>
<type>1</type>
<code>8671018402</code>
<description>Filtro antipolen - MOTRIO - Nueva</description>
<productCode>65900</productCode>
<quantity>1.00</quantity>
<unitPrice>21.35</unitPrice>
<baseAmount>21.35</baseAmount>
<discountAmount>6.40</discountAmount>
<totalAmount>14.95</totalAmount>
<partCodeList>
<partCode>65900</partCode>
</partCodeList>
<actionList>
<action>
<id>1</id>
<description>Sustituir</description>
</action>
</actionList>
</line>
</lines>
</AuthRequest>
<AuthRequest xmlns="http://www.xxxxxx.xx">
<lines>
<line>
<type>1</type>
<code>8671018402</code>
</line>
</lines>
</AuthRequest>
Means that ALL your elements are in the http://www.xxxxxx.xx
.
This means that all your elements should have the
@XmlElement(namespace="http://www.xxxxxx.xx")
and @XMLList(namespace="http://www.xxxxxx.xx")
declarations.
Thx for your help, I have solved it adding the namespace.
for me works also adding the root namespace on the "AuthRequest" class , see http://jmsyst.com/libs/serializer/master/reference/annotations#xmlnamespace
After updating in composer, the annotation XmlList stop deserializing:
Updating dependencies (including require-dev)
Updating jms/serializer (1.4.2 => 1.5.0) Checking out 9dc44f2924a90bf526a2e1c4bb1ce9d772a00a45
Updating jms/serializer-bundle (1.1.0 => 1.2.0) Checking out 95c0258b74a71ed40981998a8aa8b3bc13f9760d