环境:
开发工具:Visual Studio2019
云星空:金蝶云星空7.5
EAS:EAS8.6
1.在VS中添加登录接口和业务接口的服务引用:
引用——添加服务引用;
点击“高级”
点击“添加Web引用”
将对应接口的URL赋值到URL中,点击右侧箭头;若URL无误,然后左下的输出框中会加载出来对应的wsdl信息;然后重命名Web引用名(按个人需求)后,点击“添加引用”;
操作完成后,项目的引用下会出现名为“Web References”的文件夹,文件夹中有刚刚引用成功的工具类和wsdl等文件;
如上图,若EAS启用了安全模式,需要在调用业务接口时传入SessionId,故需要对业务接口的代理类做修改,插入红框内的代码;
调用测试::
using Kingdee.BOS.Util; using QFKJC.Util.EASLogin; using QFKJC.Util.WSVoucherInterface; using System.ComponentModel; using System.Net; namespace QFKJC.Util.EASWebService { [Description("云星空推送EAS凭证")] [HotUpdate] public class EASVoucherUtil { //安全模式时使用,调用登录接口和业务接口时保持一致 public static CookieContainer c = new CookieContainer(); public static WSContext easLogin() { System.Net.ServicePointManager.Expect100Continue = false; WSContext ctx = null; EASWebServiceModel model = new EASWebServiceModel(); string userName = model.UserName; string password = model.Password; string slnName = model.SlnName; string dcName = model.DcName; string language = model.Language; int dbType = model.DbType; EASLoginProxyService service = new EASLoginProxyService(); ctx = service.login(userName, password, slnName, dcName, language, dbType); service.CookieContainer = c; return ctx; } /// <summary> /// 凭证新增到EAS /// </summary> /// <param name="vouchers">凭证数据</param> /// <param name="isVerify">是否核销暂存</param> /// <param name="isImpCashFlow">是否包含现金流量</param> public static string[] addVoucher(WSVoucherInterface.WSWSVoucher[] vouchers, int isVerify, int isImpCashFlow) { WSContext ctx = easLogin(); WSVoucherInterfaceSrvProxyService service = new WSVoucherInterfaceSrvProxyService(); service.CookieContainer = c; KDSessionId sessionId = new KDSessionId(); sessionId.SessionId = ctx.sessionId; service.SessionId = sessionId; string[] strs = service.addVoucher(vouchers, isVerify, isImpCashFlow, "云星空"); return strs; } } }
注:以上代码只在EAS启用安全模式的情况下测试过,其他场景请自行参考下列的连接或论坛其他方式,谢谢。
参考链接:
https://vip.kingdee.com/article/43437547377459342
金蝶云星空调用EAS WebService接口(安全模式). …(535.21KB)
推荐阅读