Skip to Content
0
Former Member
May 04, 2012 at 01:44 PM

Using the SAP .NetConnector (NCO) 3.0 to set up RFC Server

1290 Views

Hi,

I am trying to set up a RFC Server which should connect to a SAP Message server with a logon group, which in turn should redirect it to the appropriate Application Server.

When connecting directly to the Application server everything works fine. When trying to use a message server while configuring the server details in the app.config file it gives a error with the attribute "GWHOST" not supported. To bypass this problem I tried hard coding the RfcConfigParameters as such:

public class SAPConfig : IDestinationConfiguration    {        public bool ChangeEventsSupported()        {            return false;        }        public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;        public RfcConfigParameters GetParameters(string destinationName)        {            var parms = new RfcConfigParameters                                              {                                                  {RfcConfigParameters.Name, "PRD"},                                                  {RfcConfigParameters.MessageServerHost, "10.0.0.XX"},                                                  {RfcConfigParameters.GatewayHost, "10.0.0.XX"},                                                  {RfcConfigParameters.Client, "XXX"},                                                  {RfcConfigParameters.LogonGroup, "GRPX"},                                                  {RfcConfigParameters.User, "USERXXX"},                                                  {RfcConfigParameters.Password, "PASSXXX"},                                                  {RfcConfigParameters.SystemNumber, "0X"},                                                  {RfcConfigParameters.Language, "EN"},                                                  {RfcConfigParameters.PoolSize, "5"}                                              };            return parms;        }    }

     class CustomRFCServerListener        {            //LISTENER THAT WAITS FOR RFC FUNCTION CALL TO THIS APPLICATION FROM WITHIN SAP            private void WriteReply(object sender, string message)            {                Console.WriteLine(message);            }            [RfcServerFunction(Name = "Z_FUNCTION_TO_LISTEN_TO")]            public static void ZfunctionToListenTo(RfcServerContext myServerContext, IRfcFunction myFunction)            {                // DO A BUNCH OF STUFF            }        }    }    //MANAGER CLASS THAT INITIATES RFC SERVER    class CustomRFCServerManager    {        private RfcServer _sapHost = null;        public void InitializeServer()        {            var rfcHandlers = new Type[1] {typeof (CustomRFCServerManager)};            var myConfig = new SAPConfig(); //Class created in code snippit above            _sapHost = RfcServerManager.GetServer(myConfig.GetParameters("PRD"), rfcHandlers);            _sapHost.Start();        }    }

As stated above everything works perfectly when connecting directly to the sap Application server. However when using this method where I try to retrieve the config data from the SAPConfig class, I get the following error: "Hard-Coded logon parameters not allowed when using a ServerConfiguration". Which is understandable, but how else can one set up a connection to a SAP Message server (MSHOST in older connector / MSSERV in the new connector)? Does anybody have an example of how the app.config should look for this scenario or is there a common solution for the attribute support issue?

Any help would be greatly appreciated!

Kind regards,

Ado