Public Class BusinessPipe
Inherits System.Web.Services.WebService
Private BUSINESS_ASSEMBLY As String = "My.Business.Assembly"
'Required by the Web Services Designer
Private components As IContainer = Nothing
'/
'/ Clean up any resources being used.
'/
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing And Not (components Is Nothing) Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub 'Dispose
Private Function AccessType(ByVal typeName As String) As Type
Dim type As Type = Nothing
Dim [assembly] As [Assembly] = System.Reflection.Assembly.Load(BUSINESS_ASSEMBLY)
If [assembly] Is Nothing Then
Throw New Exception("Could not find assembly in BusinessPipe! Assembly: " + BUSINESS_ASSEMBLY)
End If
type = [assembly].GetType((BUSINESS_ASSEMBLY + "." + typeName))
If type Is Nothing Then
Throw New Exception("Could not find type!" + ControlChars.Lf + "Assembly: " + BUSINESS_ASSEMBLY + ControlChars.Lf + "Type: " + typeName)
End If
Return type
End Function 'AccessType
'/
'/ Executes a method on the Business Logic and returns whatever object that method returns.
'/
'/ The class in the Business Logic to reference.
'/ The method that you want to execute in the class.
'/ The arguments to send to the method.
'/ The same object that the business logic method returns.
Public<WebMethod()> _
Function ExecuteMethod(typeName As String, method As String, ParamArray arguments() As Object) As Object
Dim returnObject As Object = Nothing
Dim type As Type = AccessType(TypeName)
Try
returnObject = type.InvokeMember(method, BindingFlags.Default Or BindingFlags.InvokeMethod, Nothing, Nothing, arguments)
Catch Else
'Do some custom exception handling here.
Throw
End Try
Return returnObject
End Function 'ExecuteMethod
'/
'/ Executes a method on the Business Logic and returns the same ArrayList that the method returns.
'/
'/ The class in the Business Logic to reference.
'/ The method that you want to execute in the class.
'/ The arguments to send to the method.
'/ The same object that the business logic method returns.
Public<WebMethod()> _
Function ExecuteArrayMethod(typeName As String, method As String, ParamArray arguments() As Object) As ArrayList
Dim returnObject As ArrayList = Nothing
Dim type As Type = AccessType(TypeName)
Try
returnObject = type.InvokeMember(method, BindingFlags.Default Or BindingFlags.InvokeMethod, Nothing, Nothing, arguments)
Catch Else
'Do some custom exception handling here.
Throw
End Try
Return returnObject
End Function 'ExecuteArrayMethod
End Class 'BusinessPipe