I need to upload data to SAP via a webservice, using WCF in c# 4.0 (VS2010). I have been able to connect and post data to the using the webservice successfully, however i ran into a problem with date and time.
I have an class called MtrRdngDocERPRsltCrteReqRslt having 2 fields called ActualMeterReadingDate and ActualMeterReadingTime. When Visual Studio generated the proxy class, it converted these objects as datetime objects, however I know they are Date and Time on the other end of the webservice (which is implemented in JAVA).
The problem is that when I pass datetime values to these fields, they are not getting serialized and are not being received on the other end.
Also note that when i serialize dates that are defined as DateTime by the webservice, these work perfectly.
I have also used the following code to serialize the whole object and save it locally as xml on and I have the same problem.
public void SerializeToXML(MeterReadingUploadWS2.MtrRdngDocERPRsltBulkCrteReqMsg bb, string path)
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(bb.GetType());
var serializer = new System.Xml.Serialization.XmlSerializer(bb.GetType());
using (var writer = System.Xml.XmlWriter.Create(path))
{
serializer.Serialize(writer, bb);
}
}