I'm trying to perform the deserialization of an xml to an object. The problem is that when I try to perform this operation I get the following error:
{"The specified type is not recognized: name = 'ProductTransfer', namespace = ' link ', in http://www.hotelbeds.com/schemas/2005/06/messages'> ;. "}
The xml that I'm trying to deserialize is a bit big, so I show where the error reference me is the problem:
<TransferInfo xsi:type="ProductTransfer">
<Code>0|0|0</Code>
<DescriptionList>
<Description type="GENERAL" languageCode="ENG">Private hire with driver</Description>
<Description type="PRODUCT" languageCode="ENG">Premium product type</Description>
<Description type="VEHICLE" languageCode="ENG">Minibus</Description>
</DescriptionList>
<ImageList>
<Image>
<Type>S</Type>
<Url>http://transferstatic.hotelbeds.com/giata/transfers/TRD/small/prvt-prm-mnbs.png</Url>
</Image>
<Image>
<Type>M</Type>
<Url>http://transferstatic.hotelbeds.com/giata/transfers/TRD/medium/prvt-prm-mnbs.png</Url>
</Image>
<Image>
<Type>L</Type>
<Url>http://transferstatic.hotelbeds.com/giata/transfers/TRD/large/prvt-prm-mnbs.png</Url>
</Image>
<Image>
<Type>XL</Type>
<Url>http://transferstatic.hotelbeds.com/giata/transfers/TRD/extralarge/prvt-prm-mnbs.png</Url>
</Image>
</ImageList>
<Type code="P"/>
<VehicleType code="K"/>
<TransferSpecificContent id="1129">
<GenericTransferGuidelinesList>
<TransferBulletPoint id="VINT">
<Description>INTERNATIONAL FLIGHTS</Description>
<DetailedDescription>For International flights, you are advised to be at the airport 3 hours before the departure of the flight.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="VDOM">
<Description>DOMESTIC FLIGHTS</Description>
<DetailedDescription>For domestic flights, you are advised to be at the airport 2 hours before the departure of the flight.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="VOUC">
<Description>VOUCHER </Description>
<DetailedDescription>Remember to bring this voucher and valid photo ID with you</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="CHAC">
<Description>CHANGE OF ACCOMMODATION</Description>
<DetailedDescription>If you change your accommodation during your holiday, you must inform us at least 48 hours before the departure of your flight so that we can update the details of your transfer.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="SPLU">
<Description>SPECIAL LUGGAGE</Description>
<DetailedDescription>In the event of extra luggage or sport equipment being checked in, please contact us, as this may carry an extra charge.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="STFF">
<Description>CAN'T FIND STAFF </Description>
<DetailedDescription>In the event of being unable to locate a staff member, please call the emergency number indicated in this voucher.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="LGPR">
<Description>LUGGAGE PROBLEMS</Description>
<DetailedDescription>In the event of a problem with customs or luggage, please call the emergency number in order to advise of the delay and take the necessary steps.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="CHFL">
<Description>CHANGE OF FLIGHT </Description>
<DetailedDescription>If you change your return flight during your holiday, you must inform us at least 48 hours before the departure of your flight so that we can update the details of your transfer.</DetailedDescription>
</TransferBulletPoint>
<TransferBulletPoint id="CBBS">
<Description>CHILDBOOSTER / BABY SEAT</Description>
<DetailedDescription>Child car seats and boosters are not included unless specified in your booking and can carry an extra cost. Should you need to book them, please contact your point of sale prior to travelling.</DetailedDescription>
</TransferBulletPoint>
</GenericTransferGuidelinesList>
<MaximumWaitingTime time="30">minutes</MaximumWaitingTime>
<MaximumWaitingTimeSupplierDomestic time="15">minutes</MaximumWaitingTimeSupplierDomestic>
</TransferSpecificContent>
</TransferInfo>
Part of the object that would be related to the xml is the following:
[XmlTypeAttribute(AnonymousType = true, Namespace =
"http://www.hotelbeds.com/schemas/2005/06/messages")]
[XmlRoot(ElementName="TransferInfo",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public class TransferInfo {
[XmlElement(ElementName="Code",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public string Code { get; set; }
[XmlElement(ElementName="DescriptionList",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public DescriptionList DescriptionList { get; set; }
[XmlElement(ElementName="ImageList",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public ImageList ImageList { get; set; }
[XmlElement(ElementName="Type",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public Type Type { get; set; }
[XmlAttribute (AttributeName="type",
Namespace="http://www.w3.org/2001/XMLSchema-instance")]
public string _Type { get; set; }
[XmlElement(ElementName="VehicleType",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public VehicleType VehicleType { get; set; }
[XmlElement(ElementName="TransferSpecificContent",
Namespace="http://www.hotelbeds.com/schemas/2005/06/messages")]
public TransferSpecificContent TransferSpecificContent { get; set; }
}
The code I'm using for deserialization is the following:
// objeto a transformar
var testObject = new TransferValuedAvailRS();
var xmlSerialzer = new XmlSerializer(testObject.GetType());
//responseStream es un stream
var responseStr = new StreamReader(responseStream).ReadToEnd();
using (TextReader reader = new StringReader(responseStr))
{ //deserializacion a objeto
var result = xmlSerialzer.Deserialize(reader);
}
How can I solve this error? Any suggestions? I appreciate your help. greetings friends.