I have found the answer. It is based on links above an mainly this
https://stackoverflow.com/a/2402568/4845680
I needed to make new partial class which implements new method which generates the datetime and the XML element. The old method is set to [XmlIgnore] and the new method generates XML element.
Generated Reference.cs
namespace MyService.SAPNamespace {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34234")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://sap.com/....")]
public partial class SAPClassRequestBundle : object, System.ComponentModel.INotifyPropertyChanged{
private System.DateTime zTimeField;
[System.Xml.Serialization.XmlIgnore] //This line is added so that its not used
[System.Xml.Serialization.XmlElementAttribute(Namespace="http://sap.com/....", DataType="time", Order=106)]
public System.DateTime ZTime {
get {
return this.zTimeField;
}
set {
this.zTimeField = value;
this.RaisePropertyChanged("ZTime");
}
}
}
}
My new class SapWsdlFix.cs which implements new method ZTimeString
namespace MyService.SAPNamespace {
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34234")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://sap.com/....")]
public partial class SAPClassRequestBundle : object, System.ComponentModel.INotifyPropertyChanged {
[System.Xml.Serialization.XmlElementAttribute(ElementName = "ZTime", Namespace = "http://sap.com/....", DataType = "string", Order = 106)]
public System.String ZTimeString {
get
{
return this.zTimeField.ToString("HH:mm:ss");
}
set
{
this.zTimeField = System.DateTime.ParseExact(value, "HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
this.RaisePropertyChanged("ZTime");
}
}
}
}
Differences in short for the custom class.
- ElementName-attribute is set to same as the original Reference.cs method name
DataType-attribute is changed to String from Time
[System.Xml.Serialization.XmlElementAttribute(ElementName = "ZTime", Namespace = "http://sap.com/....", DataType = "string", Order = 106)]