0

I have generated proxy from the wsdl file and it generated this way.

System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, **DataType = "time"**, Order = 8)]
public System.DateTime startTime
{
   get
   {
      return this.myTimeField;
   }
   set
   {
     this.myTimeField= value;
   }
}

See the DataType = "time" here

public partial class MyList
{
    private string xfiels;

    private System.DateTime MyTimeField;
}

Here the MYTimeField is DateTime field and the datatype field is specified as DataType = "time". 

The problem I am facing is that the service expects dates to be formatted as hh:mm:ss and the XSD generated code seems to produce only YYYY-MM-DD hh:mm:ss.

When i modify proxy class datatype to string i am recieving response from the service.

Can i Force Xml.Serializer to serialize DateTime as 'hh:mm:ss' so that i dont want to modify the generated code

Meysam Asadi
  • 6,438
  • 3
  • 7
  • 17
User1 Bas
  • 3
  • 3
  • Does this answer your question? [C# serializing Class to XML where one of class properties is DateTime. How to make this property in ISO format?](https://stackoverflow.com/questions/299387/c-sharp-serializing-class-to-xml-where-one-of-class-properties-is-datetime-how) – gunr2171 Dec 04 '21 at 02:25
  • One thing to potentially consider is NodaTime package. It has structures that are Time only (and also Date only). Might be a better fit for your needs. – B.O.B. Dec 04 '21 at 03:46
  • but the service here expects a datetime property , see inside the definition of MyList. MyTimeField is of datatype datetime . But in the System.Xml.Serialization.XmlElementAttribute it is time – User1 Bas Dec 06 '21 at 10:37
  • @gunr2171 something similar .. so this i wrote as a partial class for the proxy class because i didnt want to change the autogenerated code.. and i have recieved ambiguity between my the objects in both the classes. – User1 Bas Dec 06 '21 at 10:45

0 Answers0