Forum Discussion

liyinan357's avatar
liyinan357
New Contributor III
8 months ago

Help: Error from executing BRApi.Utilities.ExecRemoteGatewayBusinessRule

Hello,

First time posting question here. I'm a developer new to the OneStream.

 

I'm trying to run a remote business rule to pull a file that stored on Local Gateway Server. The idea is to have the content of the data file returned to OS in bytes[]. 

I have extender rule  and SIC Function rule. After I executed the Extender rule, I printed out a few things from the returned object and looks like there is an exception when executing the remote rule. Could anyone give any pointers? Any help is appreciated!

 

 Error Returned
BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteException.StackTrace)
' Returned -> 
'    at OneStream.Shared.Wcf.RelayHostInfo.InvokeRequest(IRemoteRequestBase xfRequest)
'    at OneStream.Shared.Wcf.OneStreamRelayAgent.SendRelayRequest(IRemoteRequestBase xfRequest)
BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteException.GetBaseException.Message)
' Returned -> 
'    DirectConnection
BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteResultStatus)
' Returned -> 
'    64 (which indicates an exception)

 

Here is my extender rule

Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports OneStream.Shared.Common
Imports OneStream.Shared.Wcf
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Database
Imports OneStream.Stage.Engine
Imports OneStream.Stage.Database
Imports OneStream.Finance.Engine
Imports OneStream.Finance.Database
Imports WinSCP

Namespace OneStream.BusinessRule.Extender.YL_Test
	Public Class MainClass
		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
			Try
				Dim stepNumber As String = "1"
				BRApi.ErrorLog.LogMessage(si, "1") 
				
				If (Not args.NameValuePairs Is Nothing) Then
					' Extracting the value from the parameters collection                  
					If (args.NameValuePairs.Keys.Contains("step")) Then
						stepNumber = args.NameValuePairs.Item("step")
					End If 
					BRApi.ErrorLog.LogMessage(si, "File Processing Step: " & stepNumber) 
				End If 
                
				Select Case stepNumber         
					Case Is = "1"
						GetData(si)
						Return Nothing   
				End Select    
			Catch ex As Exception
				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
			End Try
            
			Return Nothing
		End Function
   
		Public Sub GetData(ByVal si As SessionInfo)
                
			BRApi.ErrorLog.LogMessage(si,"Hello-GetData")  
			' YL_SIC_Function_Test is remote Business rule which is located in Smart Integration Function folder.
			' nonprod_sic_directconnection is the direct connect gateway name. It's setup on both OS and Local Gateway server and it's online
			' RunOperation is the function name in remote Business rule: YL_SIC_Function_Test
			Dim objRemoteRequestResultDto As RemoteRequestResultDto = BRApi.Utilities.ExecRemoteGatewayBusinessRule(si, "YL_SIC_Function_Test", Nothing, "nonprod_sic_directconnection",String.Empty,"RunOperation", True, 90)


			BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteException.StackTrace)
			BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteException.GetBaseException.Message)
			BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteResultStatus)
		End Sub    
        
	End Class
End Namespace

Here is my SIC Remote rule:

Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
'Imports System.Linq
Imports OneStreamGatewayService
Namespace OneStream.BusinessRule.SmartIntegrationFunction.YL_SIC_Function_Test
	Public Class MainClass
		Public Function RunOperation() As Byte()
			Dim filePath As String = "E:\\data_files\\Data_File.txt"
			Dim fileData As Byte() = File.ReadAllBytes(filePath)

			Return fileData

		End Function
	End Class
End Namespace

 

 

  • sniece's avatar
    sniece
    3 months ago

    Yes that did work for me as well.  I was able to connect to the local gateway server and also a local share drive for file transmission.  That's really odd that is works using a database connection gateway instead of a direct connection gateway.

    Thanks again.

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    Change/add the very first line of code to this:
    What does it show in the log?:

    BRApi.ErrorLog.LogMessage(si,objRemoteRequestResultDto.RemoteException.Message)

     

    • liyinan357's avatar
      liyinan357
      New Contributor III

      Thanks for your response!

      I added the line of code and it printed out "DirectConnection"

  • sniece's avatar
    sniece
    New Contributor II

    Did you ever find a resolution to your remote business rule exception error.  I'm trying to perform the same action and I'm getting the same error.

    Appreciate any help you can provide.

    • liyinan357's avatar
      liyinan357
      New Contributor III

      Yes we did. Try to use database connection type gateway rather than direct connection gateway. That should resolve the issue.

      • sniece's avatar
        sniece
        New Contributor II

        Yes that did work for me as well.  I was able to connect to the local gateway server and also a local share drive for file transmission.  That's really odd that is works using a database connection gateway instead of a direct connection gateway.

        Thanks again.