I've been given a wsdl and I have to create a web service following its specs; I'm using visual studio 2010. Among the others there is also the definition of this complex type:
<xsd:complexType name="Person">
<xsd:sequence>
<xsd:element name="surname" type="xsd:string"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="birthDate" nillable="true" type="xsd:dateTime"/>
</xsd:sequence>
</xsd:complexType>
Using VS I got the following cs (I don't recall exaclty how I did but I followed instructions found on the web):
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://XXX/Submitter/")]
public partial class Person {
private string surnameField;
private string nameField;
private System.Nullable<System.DateTime> birthDateField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string surname {
get {
return this.surnameField;
}
set {
this.surnameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]
public System.Nullable<System.DateTime> birthDate {
get {
return this.birthDateField;
}
set {
this.birthDateField = value;
}
}
And everything is correct: it compiles, runs and gives expected result; the only problem is that the other party that gave me the wsdl, when calling my web service, expects to get the birthdate field as
2013-02-15T17:28:00+01:00
with the time zone information, while the result they receive is like
2015-11-17T18:30:11
without timezone.
My problem is that I have a DateTime?
type and that is the one I pass to my object instantiated from the class; should I override the serialization or there is another most common solution?
Thanks