HOW TO
Calling the Buffer operation of a Geometry Service using the ArcGIS Server SOAP API returns the output buffer geometry under the geometry service namespace. When passing this geometry into the Spatial Filter under the map service namespace, a compile time error occurs. The happens because SOAP requires proxies and value objects must have the same namespace to be used together. In order to avoid this error, it is necessary to convert this geometry type from Geometry Service namespace into Map Service namespace by using .NET System.Xml.Serialization.XmlSerializer.
Code:
GeometryServer.Geometry[] outputGeometry = geometryService.Buffer(inputSpatialReference, null, null, distances, linearUnit, false, inputGeometry);
GeometryServer.PolygonN outputPolygon = (GeometryServer.PolygonN) outputGeometry[0];
Code:
Type valueType = outputPolygon.GetType();
System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(valueType);
System.Text.StringBuilder stringBuilder = new StringBuilder();
System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder);
xmlSerializer.Serialize(stringWriter, outputPolygon);
string soapSerializedValueObject = stringBuilder.ToString();
Code:
System.Xml.XmlTextReader xmlTextReader =new System.Xml.XmlTextReader(new System.IO.StringReader(soapSerializedValueObject));
System.Xml.Serialization.XmlSerializer mySerializer = new System.Xml.Serialization.XmlSerializer(typeof(MapServer.PolygonN));
object newValueObject = mySerializer.Deserialize(xmlTextReader);
MapServer.PolygonN newPolygonN = (MapServer.PolygonN)newValueObject;
Code:
SpatialFilter sf = new SpatialFilter();
sf.FilterGeometry = newPolygonN;
Article ID: 000011701
Get help from ArcGIS experts
Download the Esri Support App