SOE Elevation Data Online

This sample demonstrates how to use a custom Server Object Extension (SOE) hosted by ArcGIS for Server. The SOE operation used in this example returns a set of interpolated elevation values for a user defined grid. The grid extent and number of rows and columns are provided as inputs. More information on SOEs can be found here: http://resources.arcgis.com/en/help/main/10.1/index.html#/What_is_a_server_object_extension/0154000004s5000000/. The SOE is accessible via the ArcGIS for Server REST API. A web request is programmatically constructed by populating argument\value pairs to match parameters defined by the SOE's REST schema (discoverable via the ArcGIS for Server REST Services Directory). The response from the SOE contains string data in JSON (JavaScript Object Notation) format. There are a variety of techniques for handling JSON in WPF. This sample uses the DataContractJsonSerializer Class to deserialize the JSON response from the server. For more information on the DataContractJsonSerializer see http://msdn.microsoft.com/en-GB/library/system.runtime.serialization.json.datacontractjsonserializer(v=vs.100).aspx. The types to which the JSON is deserialized can be automatically created based on the URL or the returned JSON by using a service such as Json2CSharp (http://json2csharp.com/). Alternatively you can use the JavaScriptSerializer (http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer(v=vs.100).aspx) or there are a number of 3rd party JSON libraries available such as Json.NET (http://james.newtonking.com/projects/json-net.aspx).

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.SOEElevationData"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:esri="http://schemas.esri.com/arcgis/client/2009">

    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <esri:SimpleFillSymbol x:Key="DrawFillSymbol" Fill="#33FF0000" BorderBrush="Red" BorderThickness="1" />
        </Grid.Resources>

        <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True">
            <esri:ArcGISTiledMapServiceLayer 
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
            <esri:GraphicsLayer ID="MyGraphicsLayer"/>
        </esri:Map>

        <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" >
            <Rectangle Fill="#77919191" Stroke="Gray"  Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" Margin="10,10,10,15" />
            <StackPanel Orientation="Vertical" Margin="30,20,20,30" >
                <TextBlock Text="Enter width and height (in pixels) of a grid overlay and drag a box on the map to define grid extent.  A bitmap of average elevation values will be displayed in a separate panel." 
                           Width="200" TextAlignment="Left"  TextWrapping="Wrap" Margin="0,0,0,5"/>
                <StackPanel Orientation="Horizontal" Margin="3">
                    <TextBlock Text="Width:" VerticalAlignment="Center" Margin="3"   />
                    <TextBox x:Name="WidthTextBox" Text="15" Width="26" />
                    <TextBlock Text="Height:" Margin="9,3,3,3" VerticalAlignment="Center"  />
                    <TextBox x:Name="HeightTextBox"  Text="15" Width="26" />                
                </StackPanel>
            </StackPanel>
        </Grid>

        <Grid x:Name="ElevationView" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Visibility="Collapsed" >
            <Rectangle Fill="#77919191" Stroke="Gray"  Margin="0,0,0,5" >
                <Rectangle.Effect>
                    <DropShadowEffect/>
                </Rectangle.Effect>
            </Rectangle>
            <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" Margin="10,18,10,15" />
            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Top" Margin="0,2,8,0" >
                <Rectangle x:Name="SizeProfileImage" Stroke="Black" Fill="#00FFFFFF" Width="8" Height="4" Margin="0,0,5,0" 
                           MouseLeftButtonDown="SizeProfileImage_MouseLeftButtonDown" ToolTipService.ToolTip="Resize Image" 
                           Cursor="Hand"  />
                <TextBlock x:Name="CloseProfileImage" Foreground="Black" Text="X" 
                           MouseLeftButtonDown="CloseProfileImage_MouseLeftButtonDown" Cursor="Hand" 
                           ToolTipService.ToolTip="Close" />
            </StackPanel>
            <TextBlock Text="Elevation Grid" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="15,2,0,0" 
                       FontWeight="Bold"  />
            <Image x:Name="ElevationImage" Width="150" Height="150" Stretch="Fill" Margin="20,30,20,25" />
        </Grid>

    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014