SOE and server-side projection - am I missing something?

Discussion created by eliprandi on Oct 17, 2012
Latest reply on Oct 20, 2012 by ciava.at
We are writing an SOE that returns a geometry. In order to project the geometry to the correct spatial reference, our SOE takes a outSR (output spatial reference) parameter, similar to other esri REST endpoints. For our current test, we pass this as an argument "{"wkid":102100}".
In the SOE, we get an ISpatialReference using Conversion.ToSpatialReference(<the spatial ref argument>). At first glance, it does give us a valid ISpatialReference. When we try to project the geometry to the new spatial reference, it successfully projects the geometry. However, the result of this projection is incorrect. Not by much, but enough that the returned geometry does not line up with other geometries retrieved using the MapServer Query option.
JsonObject sr;
input.TryGetJsonObject("outSR", out sr);
ISpatialReference spatialRef = Conversion.ToSpatialReference(sr.ToJson());
// following returns something like:
// Point - x:2212717.3898518384 y:397180.12340788543
// in NAD_1927_Colorado_North system
IGeometry geometry = GetMyGeometry();
// results in: x=-11659158.62928186 y=4927334.9662179118

When we query the MapServer for the same geometry/point, it returns x=-11659216.786233451, y=4927332.1753076809. I am sure this is user error, but a couple of us have looked it and we can't seem to see what's wrong. It's such a simple sequence of code.

Thanks in advance for any help,