金蝶EAS,调用标准产品登录接口,EASLogin接口调用

来源:互联网 发布:文字解密软件 编辑:程序博客网 时间:2024/05/16 10:54

调用金蝶EAS系统提供的标准WebService接口或者二次开发提供的接口之前,都需要先调用登录接口。

下载登录接口对应的wsdl文件,生成客户端代码之后,调用实例如下(包路径根据实际情况修改):

package com.sdic.services.util;import java.net.URL;import com.sdic.services.login.EASLoginProxyServiceLocator;import com.sdic.services.login.EASLoginSoapBindingStub;import com.sdic.services.login.client.WSContext;/** * 金蝶EAS系统登录工具类 * @author 郭旭 * */public class LoginUtil {/** * 登录金蝶EAS系统 * 调用业务接口之前,需使用授权用户登录系统 * 该授权用户需要具有相应的组织范围和业务操作权限 *  */public static boolean login() throws Exception {try {EASLoginProxyServiceLocator locator = new EASLoginProxyServiceLocator();URL url = new URL(Resource.URL_LOGIN);EASLoginSoapBindingStub soap = new EASLoginSoapBindingStub(url, locator);WSContext ctx = soap.login(Resource.USERNAME, Resource.PASSWORD, Resource.SLNNAME, Resource.DBCODE, Resource.LANGUAGE, Resource.DBTYPE);if(ctx.getSessionId() == null){System.out.println("登录EAS系统失败!请检查参数配置。");} else {System.out.println("登录EAS系统成功!");System.out.println("当前登录用户:" + ctx.getUserName());System.out.println("SessionId = " + ctx.getSessionId());return true;}} catch (Exception e) {System.out.println("登录EAS系统失败!请联系开发人员。");e.printStackTrace();}return false;}/** * 登录金蝶EAS系统 * 调用业务接口之前,需使用授权用户登录系统 * 该授权用户需要具有相应的组织范围和业务操作权限 *  */public static boolean login2() throws Exception {try {EASLoginProxyServiceLocator locator = new EASLoginProxyServiceLocator();WSContext ctx = locator.getEASLogin().login(Resource.USERNAME, Resource.PASSWORD, Resource.SLNNAME, Resource.DBCODE, Resource.LANGUAGE, Resource.DBTYPE);if(ctx.getSessionId() == null){System.out.println("登录EAS系统失败!请检查参数配置。");} else {System.out.println("登录EAS系统成功!");System.out.println("当前登录用户:" + ctx.getUserName());System.out.println("SessionId = " + ctx.getSessionId());return true;}} catch (Exception e) {System.out.println("登录EAS系统失败!请联系开发人员。");e.printStackTrace();}return false;}}


接口相关配置和说明如下:
package com.sdic.services.util;/** * 资源配置,常量配置 * @author 郭旭 * */public class Resource {/**金蝶EAS系统登录接口地址**/public static final String URL_LOGIN = "http://127.0.0.1:6888/ormrpc/services/EASLogin";/**金蝶EAS系统总账接口地址**/public static final String URL_GL = "http://127.0.0.1:6888/ormrpc/services/WSGLWebServiceFacade";/**金蝶EAS系统登录账号,要求具有凭证业务权限**/public static final String USERNAME = "user";/**金蝶EAS系统登录密码**/public static final String PASSWORD = "";/**产品实例,固定值**/public static final String SLNNAME = "eas";/**金蝶EAS系统数据中心代码**/public static final String DBCODE = "T0001";/**语言:L2,简体中文;L3,繁体中文;固定值**/public static final String LANGUAGE = "L2";/**数据库类型:0,SqlServer;1,Oracle**/public static final int DBTYPE = 0;}