最近项目中需要与SAP进行数据对接,特此记录。
首先在项目中引用sapnco.dll和sapnco_utils.dll,然后在web.config配置文件中添加SAP一些主要配置信息,为获取SAP配置信息专门写了一个Common类,如下:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 public abstract class Common 2 { 3 /// <summary> 4 /// 获取SAP配置信息 5 /// </summary> 6 public static SAPServerInfoModel GetSapServerInfo() 7 { 8 SAPServerInfoModel sapInfo = new SAPServerInfoModel 9 { 10 NAME = ConfigurationManager.AppSettings["NAME"], 11 ASHOST = ConfigurationManager.AppSettings["ASHOST"], 12 CLIENT = ConfigurationManager.AppSettings["CLIENT"], 13 USER = ConfigurationManager.AppSettings["USER"], 14 PASSWD = ConfigurationManager.AppSettings["PASSWD"], 15 SYSNR = ConfigurationManager.AppSettings["SYSNR"], 16 LANG = ConfigurationManager.AppSettings["LANG"] 17 }; 18 return sapInfo; 19 } 20 }
为初始化SAP配置信息添加了个SAPConfiguration类,如下:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
public class SAPConfiguration : IDestinationConfiguration { public bool ChangeEventsSupported() { return false; } public event RfcDestinati