How to use Geometry Buffer Service on a Polyline?

Discussion created by tim2u on Oct 2, 2012
I am able to use the geometry service buffer functionality on a MapPoint and a List of MapPoints. However, I can not seem to get it to work with a polyline geometry (see code attempt below).  It will result into the failed callback with an innerException: "Unable to complete operation".

Can we buffer a polyline using the geometry service?  If so, any examples on how to do so? I'd prefer not to use a GP tool if possible. 

My current workaround (although inefficient) is to geodesify the polyline and create a list of graphics from each path's point collection of the geodesified geometry.  I then pass that list to the buffer operation and it works fine. 

            Polyline myLine = new Polyline();
            PointCollection myPC = new PointCollection();
            foreach (MapPoint refMP in myMapPoints) myPC.Add(refMP);

            Geometry myRoute = _mercator.FromGeographic(myLine);
            myRoute.SpatialReference = MyMap.SpatialReference;
            Graphic graphicToBuffer = new Graphic()
                Geometry = myRoute,
                Symbol = LayoutRoot.Resources["RouteLineSymbol"] as LineSymbol

            BufferParameters bufferParams = new BufferParameters()
                Unit = LinearUnit.NauticalMile,
                BufferSpatialReference = new SpatialReference(4326), //WGS 1984
                OutSpatialReference = MyMap.SpatialReference,
            LocalGeometryService myGS = LocalGeometryService.GetService();
            GeometryService myTask = new GeometryService();
            myTask.Url = myGS.UrlGeometryService;
            myTask.BufferCompleted += new EventHandler<GraphicsEventArgs>(myTask_BufferCompleted);
            myTask.Failed += new EventHandler<TaskFailedEventArgs>(myTask_Failed);