I am just learning WCF services. I have a method that returns an object I created called GPSPosition. A GPS Position object has a Latitude and a Longitude. The object should never really exist without these properties.. So, I want to have the constructor accept the Lat and Long floats. So when the object is created, the values are set, and can never be invalid (Unset).
But, it's an object of my WCF service. Can as WCF service object, that my calling application uses, have a constructor? If I var position = new GpsPosition{ lat=1, lon=1 };
in my calling code, will the constructor work? Can you have constructors in WCF classes?
I thought they are shared among different languages - so if the service is used by Java, for example, I'm unsure how the constructor will fire. The object structure is shared to the calling app, no? Can you fire .net code in the constructor (And getter and setter methods, for that case)?
And if the constructor isn't usable - is there a way to ensure my object is never invalid? (Must have valid lat/long values between -180 and +180)?