About the Simple REST SOE Sample
[C#]
SimpleRESTSOE_VBNet.cs
[Visual Basic .NET]
SimpleRESTSOE_VBNet.vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.EnterpriseServices
Imports ESRI.ArcGIS.Server
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.SOESupport
Imports System.Collections.Specialized
Namespace SimpleRESTSOE_VBNet
<ComVisible(True), Guid("4FC42575-D03C-4059-A7C8-BBFB05B34B67"), ClassInterface(ClassInterfaceType.None)> _
Public Class SimpleRESTSOE_VBNet
Inherits ServicedComponent
Implements IServerObjectExtension, IObjectConstruct, IRESTRequestHandler
Private _reqHandler As IRESTRequestHandler
Public Sub New()
Dim rootResource As RestResource = CreateRestSchema()
Dim restImpl As New SoeRestImpl("SimpleRESTSOE_VBNet", rootResource)
_reqHandler = CType(restImpl, IRESTRequestHandler)
End Sub
Public Sub Init(ByVal pSOH As IServerObjectHelper) Implements IServerObjectExtension.Init
End Sub
Public Sub Shutdown() Implements IServerObjectExtension.Shutdown
End Sub
Public Overloads Sub Construct(ByVal props As IPropertySet) Implements IObjectConstruct.Construct
End Sub
Private Function CreateRestSchema() As RestResource
Dim soeResource As New RestResource("SimpleRESTSOE_VBNet", False, AddressOf RootSOE)
Dim findNearFeatsOp As New RestOperation("echo", New String() {"text"}, New String() {"json", "html"}, AddressOf EchoInput)
soeResource.operations.Add(findNearFeatsOp)
Return soeResource
End Function
Public Function GetSchema() As String Implements IRESTRequestHandler.GetSchema
Return _reqHandler.GetSchema()
End Function
Private Function HandleRESTRequest(ByVal Capabilities As String, ByVal resourceName As String, ByVal operationName As String, ByVal operationInput As String, ByVal outputFormat As String, ByVal requestProperties As String, <System.Runtime.InteropServices.Out()> ByRef responseProperties As String) As Byte() Implements IRESTRequestHandler.HandleRESTRequest
Return _reqHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, responseProperties)
End Function
Private Function RootSOE(ByVal boundVariables As System.Collections.Specialized.NameValueCollection, ByVal outputFormat As String, ByVal requestProperties As String, <System.Runtime.InteropServices.Out()> ByRef responseProperties As String) As Byte()
responseProperties = Nothing
Dim jObject As New JsonObject()
Return Encoding.UTF8.GetBytes(jObject.ToJson())
End Function
Private Function EchoInput(ByVal boundVariables As System.Collections.Specialized.NameValueCollection, ByVal operationInput As ESRI.ArcGIS.SOESupport.JsonObject, ByVal outputFormat As String, ByVal requestProperties As String, <System.Runtime.InteropServices.Out()> ByRef responseProperties As String) As Byte()
responseProperties = Nothing
Dim inputText As String
If (Not operationInput.TryGetString("text", inputText)) Then
Throw New ArgumentNullException("text")
End If
Dim jObject As New JsonObject()
jObject.AddString("text", inputText)
Return Encoding.UTF8.GetBytes(jObject.ToJson())
End Function
End Class
End Namespace