ArcObjects Library Reference  

SimpleSoapSOE_VBNet

About the Simple SOAP SOE Sample

[C#]

SimpleSoapSOE_VBNet.cs


[Visual Basic .NET]

SimpleSoapSOE_VBNet.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.EnterpriseServices
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Server
Imports ESRI.ArcGIS.SOESupport

Namespace SimpleSoapSOE_VBNet
  <ComVisible(True), Guid("71010E8B-805E-49d2-AD3D-9E1642C9CD4F"), ClassInterface(ClassInterfaceType.None)> _
  Public Class SimpleSoapSOE_VBNet
    Inherits ServicedComponent
    Implements IRequestHandler2, IServerObjectExtension, IObjectConstruct


    Private Const c_SOEName As String = "SimpleSoapSOE_VBNet"
    Friend Const c_SOENamespace As String = "http://examples.esri.com/schemas/SimpleSoapSOE_VBNet/1.0"
    Friend Const c_ESRINamespace As String = "http://www.esri.com/schemas/ArcGIS/10.0"

    Private reqHandler As IRequestHandler2

    Public Sub New()
      Dim soapCapabilities As New SoapCapabilities()
      soapCapabilities.AddMethod("EchoInput", "Echo")

      Dim soapImpl As New SoeSoapImpl(c_SOEName, soapCapabilities, AddressOf HandleSoapMessage)
      reqHandler = CType(soapImpl, IRequestHandler2)
    End Sub

#Region "IServerObjectExtension"
    Public Sub Init(ByVal pSOH As IServerObjectHelper) Implements IServerObjectExtension.Init
    End Sub

    Public Sub Shutdown() Implements IServerObjectExtension.Shutdown
    End Sub
#End Region

#Region "IRequestHandler"

    Public Function HandleBinaryRequest(ByRef request() As Byte) As Byte() Implements ESRI.ArcGIS.esriSystem.IRequestHandler.HandleBinaryRequest
      Throw New NotImplementedException()
    End Function

    Public Function HandleStringRequest(ByVal Capabilities As String, ByVal request As String) As String Implements ESRI.ArcGIS.esriSystem.IRequestHandler.HandleStringRequest
      Return reqHandler.HandleStringRequest(Capabilities, request)
    End Function

    Public Function HandleBinaryRequest1(ByRef request() As Byte) As Byte() Implements ESRI.ArcGIS.esriSystem.IRequestHandler2.HandleBinaryRequest
      Throw New NotImplementedException()
    End Function

    Public Function HandleBinaryRequest2(ByVal Capabilities As String, ByRef request() As Byte) As Byte() Implements ESRI.ArcGIS.esriSystem.IRequestHandler2.HandleBinaryRequest2
      Throw New NotImplementedException()
    End Function

    Public Function HandleStringRequest1(ByVal Capabilities As String, ByVal request As String) As String Implements ESRI.ArcGIS.esriSystem.IRequestHandler2.HandleStringRequest
      Return reqHandler.HandleStringRequest(Capabilities, request)
    End Function


#End Region

#Region "IObjectConstruct"
    Public Overloads Sub Construct(ByVal props As IPropertySet) Implements IObjectConstruct.Construct
    End Sub
#End Region


    Public Sub HandleSoapMessage(ByVal reqMsg As IMessage, ByVal respMsg As IMessage)
      Dim methodName As String = reqMsg.Name

      If String.Compare(methodName, "EchoInput", True) = 0 Then
        EchoInput(reqMsg, respMsg)

      Else
        Throw New ArgumentException(String.Format("Method not supported: {0}.{1}", c_SOEName, methodName))
      End If
    End Sub

    Private Sub EchoInput(ByVal reqMsg As IMessage, ByVal respMsg As IMessage)
      Dim reqParams As IXMLSerializeData = reqMsg.Parameters

      Dim inputString As String = reqParams.GetString(FindParam("Text", reqParams))

      respMsg.Name = "EchoInputResponse"
      respMsg.NamespaceURI = c_SOENamespace
      respMsg.Parameters.AddString("Result", inputString)
    End Sub

    Private Function FindParam(ByVal parameterName As String, ByVal msgParams As IXMLSerializeData) As Integer
      Dim idx As Integer = msgParams.Find(parameterName)
      If idx = -1 Then
        Throw New ArgumentNullException(parameterName)
      End If
      Return idx
    End Function



  End Class
End Namespace