cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Connector 3.0 error service '?' unknown

RobEricsson
Participant
0 Kudos

Hello,

I'm trying to do something very simple using the .NET Connector 3.0 and am getting the following exception when trying to access the RfcDestination:

LOCATION CPIC (TCP/IP) on local host RERICSSON with Unicode

ERROR service '?' unknown

TIME Tue Sep 06 21:28:41 2011

RELEASE 720

COMPONENT NI (network interface)

VERSION 40

RC -3

DETAIL NiErrSe

COUNTER 2

I'm basically using the example from "A Spotlight on the New .NET Connector 3.0" (/people/thomas.weiss/blog/2011/01/14/a-spotlight-on-the-new-net-connector-30) in Visual Studio 2010 with .NET 4.0 but I must be missing some configuration or another.

I can connect to my SAP instance from the my local host via SAP GUI. I remember with JCo, there was sometimes the need to add a service entry to the services file, but the service '?' unknown seems to point to something different.

The code looks like:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAP.Middleware.Connector;

namespace TestNCo
{
    class Program
    {
        static void Main(string[] args)
        {
            RfcDestinationManager.RegisterDestinationConfiguration(new
     MyBackendConfig());//1
            RfcDestination prd = RfcDestinationManager.
               GetDestination("PRD_000");//2
            try
            {

                RfcRepository repo = prd.Repository;//3                    
                IRfcFunction companyBapi =
                   repo.CreateFunction
                  ("BAPI_COMPANY_GETDETAIL");//4              
                companyBapi.SetValue("COMPANYID", "001000"); //5
                companyBapi.Invoke(prd); //6
                IRfcStructure detail = companyBapi.
                  GetStructure("COMPANY_DETAIL");
                String companyName = detail.
                  GetString("NAME1");//7                
                Console.WriteLine(companyName);
                Console.Read();
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.Read();
            }
        }

        public class MyBackendConfig : IDestinationConfiguration
        {
            public RfcConfigParameters GetParameters(String destinationName)
            {
                if ("PRD_000".Equals(destinationName))
                {
                    RfcConfigParameters parms = new RfcConfigParameters();
                    parms.Add(RfcConfigParameters.MessageServerHost,
                          "some.ABAP.host");
                    parms.Add(RfcConfigParameters.LogonGroup, "PUBLIC");
                    parms.Add(RfcConfigParameters.SystemID, "ID1");
                    parms.Add(RfcConfigParameters.User, "user");
                    parms.Add(RfcConfigParameters.Password, "password");
                    parms.Add(RfcConfigParameters.Client, "800");
                    parms.Add(RfcConfigParameters.Language, "en");
                    parms.Add(RfcConfigParameters.PoolSize, "5");
                    parms.Add(RfcConfigParameters.MaxPoolSize, "10");
                    parms.Add(RfcConfigParameters.IdleTimeout, "600");
                    return parms;
                }
                else return null;
            }
            // The following two are not used in this example:
            public bool ChangeEventsSupported()
            {
                return false;
            }
            public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;
        }
    }
}

Any suggestions would be welcome.

Thanks.

Rob

Accepted Solutions (0)

Answers (2)

Answers (2)

hynek_petrak
Active Participant
0 Kudos

Hi,

you were very close. The .NET Connector need to know the port of the message server, in case of load balanced target.

Either

  1. You set the port via Windows\system32\drivers\etc\services file, putting sapmsID1 36xx/tcp
  2. You set parms.Add(RfcConfigParameters.MessageServerService, 36xx);

Where 36xx is you message server port. Usually xx equals to the Instance number.

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

one more remark: Message server ports are proposed to be in the range of 36xx. However, it's not limited to that range. The message server could also listen on other ports.

Best regards,

Markus

RobEricsson
Participant
0 Kudos

I figured this out. I was trying to connect to the message server per the example when I should have been connecting to the app server directly. A simple change of RfcConfigParameters.MessageServerHost to RfcConfigParameters.AppServerHost and it works fine.