您的位置:首页 > 其它

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

2017-06-02 10:46 399 查看
调用金蝶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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息