金蝶 EAS WebService 启动安全性后的调用方法原创
3人赞赏了该文章
1,015次浏览
编辑于2020年11月24日 08:45:24
金蝶EAS WebService开启安全性后,调用方法代码
首先登录获取 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();}123456
调用方法前,先获取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(); }}1234567891011
引入的类/包名
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;1234567
需要的jar包
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>
赞 3
3人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读
您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!
请选择打赏金币数 *
10金币20金币30金币40金币50金币60金币
可用金币: 0