I am hoping someone can help me with this.
I need to serialize a request from XML so that it can be converted into a SOAP call. The problem is, I am having trouble succeeding when the xml is missing a xmlns definition.
First of all, I have a class called GetRegistrationStatusRequest. This was auto generated using the XSD tool from a customer provided XSD. The class looks as follows (Note that I have replaced the client sensitive URL)
//
// This source code was auto-generated by xsd, Version=4.0.30319.18020.
//
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.18020")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://some.url/srvc/getregistrationstatus/v1_0/request/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://some.url/srvc/getregistrationstatus/v1_0/request/", IsNullable=false)]
public partial class GetRegistrationStatusRequest : ServiceRequest {
... auto generated code
As mentioned, this is auto generated. I have included it for reference.
My Code for actually deserializing the Xml is as follows:
XmlSerializer serializer = new XmlSerializer(typeof(GetRegistrationStatusRequest));
GetRegistrationStatusRequest request = (GetRegistrationStatusRequest)serializer.Deserialize(new StringReader(RequestXml.OuterXml));
If I use XML as follows, it works fine:
<GetRegistrationStatusRequest xmlns="http://some.url//srvc/getregistrationstatus/v1_0/request/">
<PlateNo>PlateNo1</PlateNo>
</GetRegistrationStatusRequest>
However the XML that I am receiving (which is out of my control) does not have the xmlns defined. Instead it looks like this:
<GetRegistrationStatusRequest>
<PlateNo>PlateNo1</PlateNo>
</GetRegistrationStatusRequest>
When I attempt to deserialize this I get the message "The is an arror in XML document (1,2)"
I am wondering if it is actually possible to get the Xml to deserialize without needing the xmlns definition?
Any help would be greatly appreciated.