金蝶 EAS WebService 启动安全性后的调用方法

金蝶EAS WebService开启安全性后,调用方法代码

  1. 首先登录获取 SessionID
public static String login() throws ServiceException, RemoteException {
    EASLoginProxyServiceLocator locator = new EASLoginProxyServiceLocator();
    EASLoginProxy login = locator.getEASLogin();
    WSContext context = login.login("xxx", "xxx", "eas", "xxx", "L2", 1);
    return context.getSessionId();
}
  1. 调用方法前,先获取SessionID
String sessionID = login();
  1. 调用具体方面前,设置head头信息
((Stub) proxy).setHeader("http://login.webservice.bos.kingdee.com", "SessionId", sessionID);
  1. 整合起来如下:
public static void testMaterial() throws RemoteException, ServiceException {
    String sessionID = login();
    WSMaterialWSFacadeSrvProxyService service = new WSMaterialWSFacadeSrvProxyServiceLocator();
    try {
        WSMaterialWSFacadeSrvProxy proxy= service.getWSMaterialWSFacade();
        ((Stub) proxy).setHeader("http://login.webservice.bos.kingdee.com", "SessionId", sessionID);
        System.out.println("materialInfo:" + wsFacade.getMaterialInfo());
    } catch (RemoteException | ServiceException e) {
        e.printStackTrace();
    }
}
  1. 引入的类/包名
import com.kingdee.eas.xxx.login.webservice.EASLoginProxy;
import com.kingdee.eas.xxx.login.webservice.EASLoginProxyServiceLocator;
import com.kingdee.eas.xxx.login.webservice.WSContext;
import com.kingdee.eas.xxx.material.webservice.WSMaterialWSFacadeSrvProxy;
import com.kingdee.eas.xxx.material.webservice.WSMaterialWSFacadeSrvProxyService;
import com.kingdee.eas.xxx.material.webservice.WSMaterialWSFacadeSrvProxyServiceLocator;
import org.apache.axis.client.Stub;
  1. 需要的jar包
    在这里插入图片描述
  2. POM依赖
<dependencies>
  <dependency>
    <groupId>commons-beanutils</groupId>
    <artifactId>commons-beanutils</artifactId>
    <version>1.9.3</version>
  </dependency>
  <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
  </dependency>
  <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.6</version>
  </dependency>
  <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
  </dependency>
  <dependency>
    <groupId>net.sf.ezmorph</groupId>
    <artifactId>ezmorph</artifactId>
    <version>1.0.6</version>
  </dependency>
  <dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>2.4</version>
    <classifier>jdk15</classifier>
  </dependency>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
  </dependency>
</dependencies>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值