About the Simple SOAP SOE Sample
[C#]
Program.cs
using System;
namespace RegisterSimpleSoapSOE
{
class Program
{
static void Main(string[] args)
{
// Must run as an user in the agsadmin group on the SOM
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection =
new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection();
agsServerConnection.Host = "localhost";
agsServerConnection.Connect();
ESRI.ArcGIS.Server.IServerObjectAdmin2 serverObjectAdmin =
agsServerConnection.ServerObjectAdmin as ESRI.ArcGIS.Server.IServerObjectAdmin2;
// This name must match those defined for property pages
string extensionName = "SimpleSoapSOE";
// Check command line arguments to see if SOE is to be unregistered
if (args.Length == 1 && args[0] == "/unregister")
{
// Check whether the SOE is registered
if (ExtensionRegistered(serverObjectAdmin, extensionName))
{
// Delete the SOE
serverObjectAdmin.DeleteExtensionType("MapServer", extensionName);
Console.WriteLine(extensionName + " successfully unregistered");
}
else
Console.WriteLine(extensionName + " is not registered with ArcGIS Server");
}
else
{
// Check whether the SOE is registered
if (!ExtensionRegistered(serverObjectAdmin, extensionName))
{
// Use IServerObjectExtensionType3 to get access to info properties
ESRI.ArcGIS.Server.IServerObjectExtensionType3 serverObjectExtensionType =
serverObjectAdmin.CreateExtensionType() as ESRI.ArcGIS.Server.IServerObjectExtensionType3;
// Must match the namespace and class name of the class implementing IServerObjectExtension
serverObjectExtensionType.CLSID = "SimpleSoapSOE.SimpleSoapSOE";
serverObjectExtensionType.Description = "Demonstrates SOE implementation with SOAP";
serverObjectExtensionType.Name = extensionName;
// Name that will be shown in the capabilities list on property pages
serverObjectExtensionType.DisplayName = "Simple Soap SOE";
// Use info properties to define capabilities and msd support
serverObjectExtensionType.Info.SetProperty("DefaultWebCapabilities", "Echo");
serverObjectExtensionType.Info.SetProperty("AllWebCapabilities", "Echo");
serverObjectExtensionType.Info.SetProperty("SupportsMSD", "true");
// Register the SOE with the server
serverObjectAdmin.AddExtensionType("MapServer", serverObjectExtensionType);
Console.WriteLine(extensionName + " successfully registered with ArcGIS Server");
}
else
Console.WriteLine(extensionName + " is already registered with ArcGIS Server");
}
Console.ReadLine();
}
// Checks whether an extension with the passed-in name is already registered with the passed-in server
static private bool ExtensionRegistered(ESRI.ArcGIS.Server.IServerObjectAdmin2 serverObjectAdmin, string extensionName)
{
// Get the extensions that extend MapServer server objects
ESRI.ArcGIS.Server.IEnumServerObjectExtensionType extensionTypes = serverObjectAdmin.GetExtensionTypes("MapServer");
extensionTypes.Reset();
// If an extension with a name matching that passed-in is found, return true
ESRI.ArcGIS.Server.IServerObjectExtensionType extensionType = extensionTypes.Next();
while (extensionType != null)
{
if (extensionType.Name == extensionName)
return true;
extensionType = extensionTypes.Next();
}
// No matching extension was found, so return false
return false;
}
}
}
[Visual Basic .NET]
Program.vb
Imports Microsoft.VisualBasic
Imports System
Namespace RegisterSimpleSoapSOE_VBNet
Friend Class Program
Shared Sub Main(ByVal args() As String)
' Must run as an user in the agsadmin group on the SOM
Dim agsServerConnection As New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection()
agsServerConnection.Host = "localhost"
agsServerConnection.Connect()
Dim serverObjectAdmin As ESRI.ArcGIS.Server.IServerObjectAdmin2 = TryCast(agsServerConnection.ServerObjectAdmin, ESRI.ArcGIS.Server.IServerObjectAdmin2)
' This name must match those defined for property pages
Dim extensionName As String = "SimpleSoapSOE_VBNet"
' Check command line arguments to see if SOE is to be unregistered
If args.Length = 1 AndAlso args(0) = "/unregister" Then
' Check whether the SOE is registered
If ExtensionRegistered(serverObjectAdmin, extensionName) Then
' Delete the SOE
serverObjectAdmin.DeleteExtensionType("MapServer", extensionName)
Console.WriteLine(extensionName & " successfully unregistered")
Else
Console.WriteLine(extensionName & " is not registered with ArcGIS Server")
End If
Else
' Check whether the SOE is registered
If (Not ExtensionRegistered(serverObjectAdmin, extensionName)) Then
' Use IServerObjectExtensionType3 to get access to info properties
Dim serverObjectExtensionType As ESRI.ArcGIS.Server.IServerObjectExtensionType3 = TryCast(serverObjectAdmin.CreateExtensionType(), ESRI.ArcGIS.Server.IServerObjectExtensionType3)
' Must match the namespace and class name of the class implementing IServerObjectExtension
serverObjectExtensionType.CLSID = "SimpleSoapSOE_VBNet.SimpleSoapSOE_VBNet"
serverObjectExtensionType.Description = "Demonstrates SOE implementaion using SOAP."
serverObjectExtensionType.Name = extensionName
' Name that will be shown in the capabilities list on property pages
serverObjectExtensionType.DisplayName = "Simple Soap SOE VBNet"
' Use info properties to define capabilities and msd support
serverObjectExtensionType.Info.SetProperty("DefaultWebCapabilities", "Echo")
serverObjectExtensionType.Info.SetProperty("AllWebCapabilities", "Echo")
serverObjectExtensionType.Info.SetProperty("SupportsMSD", "true")
' Register the SOE with the server
serverObjectAdmin.AddExtensionType("MapServer", serverObjectExtensionType)
Console.WriteLine(extensionName & " successfully registered with ArcGIS Server")
Else
Console.WriteLine(extensionName & " is already registered with ArcGIS Server")
End If
End If
Console.ReadLine()
End Sub
' Checks whether an extension with the passed-in name is already registered with the passed-in server
Private Shared Function ExtensionRegistered(ByVal serverObjectAdmin As ESRI.ArcGIS.Server.IServerObjectAdmin2, ByVal extensionName As String) As Boolean
' Get the extensions that extend MapServer server objects
Dim extensionTypes As ESRI.ArcGIS.Server.IEnumServerObjectExtensionType = serverObjectAdmin.GetExtensionTypes("MapServer")
extensionTypes.Reset()
' If an extension with a name matching that passed-in is found, return true
Dim extensionType As ESRI.ArcGIS.Server.IServerObjectExtensionType = extensionTypes.Next()
Do While extensionType IsNot Nothing
If extensionType.Name = extensionName Then
Return True
End If
extensionType = extensionTypes.Next()
Loop
' No matching extension was found, so return false
Return False
End Function
End Class
End Namespace