.net平台调用SAP RFC的几种方案

第一种方式采用SAP.net Connector:

最新版本是3.01,不开源,不知道有没有官方的技术支持。从3.0版本开始,使用方法上开始跟2.0相差很大,不再需要生成代理类,好处是一旦SAP RFC接口做了更改,不需要重新生成代理类。凡是都有两面性,这个好处也可以看做一个缺点:如果对RFC信息比较少,你不能用代理类的方式取得参数和者返回值的数据结构。

                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.MessageServerHost, SAP Server IP);
                parms.Add(RfcConfigParameters.GatewayHost, SAP Server IP);
                //parms.Add(RfcConfigParameters.GatewayService, SAP Server IP);
                parms.Add(RfcConfigParameters.SystemID, "SB6"); // Set actual System ID
                parms.Add(RfcConfigParameters.SystemNumber, "02"); //// Set actual System Number
                parms.Add(RfcConfigParameters.User, "test");
                parms.Add(RfcConfigParameters.Password, "test");
                parms.Add(RfcConfigParameters.Client, "120"); // Set actual client ID
                parms.Add(RfcConfigParameters.Language, "EN");
                parms.Add(RfcConfigParameters.PoolSize, "5");
                parms.Add(RfcConfigParameters.MaxPoolSize, "10");
                parms.Add(RfcConfigParameters.IdleTimeout, "600");

                RfcRepository repo = prd.Repository;                   
                IRfcFunction companyBapi = repo.CreateFunction(RFC Name);           
                companyBapi.SetValue(Parameter name, value);
                companyBapi.Invoke(prd);
                object o = companyBapi.GetValue(return parameter name);   
                Console.WriteLine(o);

第二种方式采用纯粹的Biztalk Adapter,不用Biztalk Server:

               新建一个Console Application, 添加“add adapter service reference...”, 弹出下面的窗口

              

        点击Configuration配置好SAP Server的基本信息,包括服务器地址, System Number, Client, 访问SAP的用户名和密码。

               配置完后,测试连接是否OK, 如果没有问题可以列出RFC,IDOC之类的SAP世界里的东东,过滤出需要的RFC

              

               填入一个合适的文件名前缀,默认是SAPBinging,点击OK生成一个WCF代理类,命名方式是 文件名前缀+Client.cs,

               这里是SAPBindingClient.cs。然后你肯定就知道该怎么用它了:)

第三种方式是用Biztalk Server 2010:

        

             具体步骤参考Biztalk Adapter的帮助文档,需要注意的是,如上图SendToLOBPort这个双向Port包含的方法名称"Operation_1"需要更改成RFC的名字或者修改Schema文件(参考 Troubleshooting Operational Issues):

  • Change the operation name in the logical port in BizTalk orchestration from Operation_1, etc. to the operation for which you generate metadata, for example RFC_CUSTOMER_GET.

  • Change the operation name in the action on the physical port to the operation name in the logical port.

计划下一步加上这三种方法的性能,并发,容错测试分析。

建议博客园加上企业级服务的文章分类.

posted @ 2011-07-05 17:15  Patrick Yu  阅读(4603)  评论(0编辑  收藏  举报