I have problems deserializing this XML.
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getBasketResponse xmlns:ns="http://capi.basket.webservice.wg_base_app.enfinity.wg.com">
<ns:return xmlns:ax27="http://capi.webservice.wg_base_app.enfinity.wg.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax27:Response">
<ax27:costs xsi:type="ax27:Cost">
<ax27:name>Verwerking (verpakking & levering)</ax27:name>
</ax27:costs>
</ns:return>
</ns:getBasketResponse>
</soapenv:Body>
</soapenv:Envelope>
These are my classes:
public class GetBasketResponse
{
[XmlElement("ns:return")] public ReturnData ReturnData { get; set; }
}
public class ReturnData
{
[XmlElement("ax27:costs", Namespace= "http://capi.webservice.wg_base_app.enfinity.wg.com/xsd")]
public List<Cost> Costs { get; set; }
}
public class Cost
{
[XmlElement("ax27:name", Namespace = "http://capi.webservice.wg_base_app.enfinity.wg.com/xsd")]
public string Name { get; set; }
}
This is my code to deserialize:
XmlSerializer serializer = new XmlSerializer(typeof(GetBasketResponse));
using (StringReader reader = new StringReader(xml))
{
GetBasketResponse result = (GetBasketResponse)serializer.Deserialize(reader);
}
Error: InvalidOperationException: The specified type was not recognized: name='Response', namespace='http://capi.webservice.wg_base_app.enfinity.wg.com/xsd', at <return xmlns='http://capi.basket.webservice.wg_base_app.enfinity.wg.com'>.