cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Iain,

That is exactly what I use to connect to the Application Server directly. However I need to be able to connect to the message server which should then redirect me to the correct application server. The older dNCO could do this by specifying the MSHOST and LOGON group I believe. For the new one I have not yet seen anything that works in the same way.

Regards,

Ado

0 Kudos

You must chance the ASHOST to MSHOST, in wich MSHOST is the IP or network name of your message server. And also include in the ClientSettings, the GROUP parameter, wich is the Group Server Name.

And the GWHOST on the ServerConfiguration, is the IP of your message Server. It is the same value from MSHOST on ClientSettings

This way, you use balanced loading to connect,

  <SAP.Middleware.Connector>

    <ClientSettings>

      <DestinationConfiguration>

        <destinations>

          <add NAME="PROD_CLIENT" USER="USERNAME" PASSWD="THEPASSWORD" CLIENT="401" LANG="ES" MSHOST="MsgServer_IP" GROUP="ERP_PROD" SYSID="P03" SYSNR="00" MAX_POOL_SIZE="10" POOL_SIZE="10" IDLE_TIMEOUT="10"/>

        </destinations>

      </DestinationConfiguration>

    </ClientSettings>

    <ServerSettings>

      <ServerConfiguration>

        <servers>

          <add NAME="PROD_SERVER" GWHOST="XXX.XXX.XXX.XXX"

               GWSERV="SAPGW00" PROGRAM_ID="RFCGBA_DES"

               REPOSITORY_DESTINATION="PROD_CLIENT" REG_COUNT="1"/>

        </servers>

      </ServerConfiguration>

    </ServerSettings>

  </SAP.Middleware.Connector>

Hope it helps,

Genaro.

Former Member
0 Kudos

If someone might have documentation on how to do this that will also suffice. Just have to get this working

Former Member
0 Kudos

Am i looking at this too simplistically or would this do the job for you:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <configSections>

    <sectionGroup name="SAP.Middleware.Connector">

      <sectionGroup name ="ClientSettings">

        <section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco" />      

      </sectionGroup>

      <sectionGroup name="ServerSettings">

        <section name="ServerConfiguration" type="SAP.Middleware.Connector.RfcServerConfiguration, sapnco"/>

      </sectionGroup>          

    </sectionGroup

  </configSections>

  <SAP.Middleware.Connector>

    <ClientSettings>

      <DestinationConfiguration>

        <destinations>

          <add NAME="DEV" USER="username" PASSWD="pswd" CLIENT="200" LANG="EN" ASHOST="server.domain"

               SYSNR="00" MAX_POOL_SIZE="10" IDLE_TIMEOUT="10"/>

      </destinations>

      </DestinationConfiguration>

    </ClientSettings>

    <ServerSettings>

      <ServerConfiguration>

        <servers>

          <add NAME="MY_SERVER" GWHOST="server.domain" GWSERV="SAPGW00" PROGRAM_ID="NCO3_RFC_SERVER"

               REPOSITORY_DESTINATION="DEV" REG_COUNT="1"/> 

        </servers>   

      </ServerConfiguration>

    </ServerSettings>  

  </SAP.Middleware.Connector>

  <startup>

    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

  </startup

</configuration>