Eclipse调用WebService(9)

栏目:eas cloud知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

Eclipse调用WebService(9)

## 下载login和接口对应的wsdl文件 并将wsdl引入到Eclipse中: ![image20210726232558358.webp](/download/0100c250b6f2491c43c7bc2b8595f01dfb22.webp) ## 发布wsdl文件 ![image20210726232631803.webp](/download/0100f8ad2dba27764f8c9cf805b96ba98d35.webp) ## 新建实现类 ![image20210726232904596.webp](/download/01006c6d49ceac1b4e2b93cd753a1ee43c5c.webp) 添加实现代码: ```java package client; import org.apache.axis.client.Stub; import _1._0._0._127.ormrpc.services.EASLogin.EASLoginProxyProxy; import _1._0._0._127.ormrpc.services.WSjczlFacade.WSjczlFacadeSrvProxy; import _1._0._0._127.ormrpc.services.WSjczlFacade.WSjczlFacadeSrvProxyServiceLocator; public class TestFacade { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub EASLoginProxyProxy login = new EASLoginProxyProxy(); WSContext ctx = login.login("wj", "", "eas", "EASLearn", "l2", 0); System.out.println(ctx.getSessionId()); WSjczlFacadeSrvProxy wsesProxy = new WSjczlFacadeSrvProxyServiceLocator().getWSjczlFacade(); ((Stub)wsesProxy).setHeader("http://login.webservcie.bos.kingdee.com","SessionId",ctx.getSessionId()); String jsonData = "{\"number\":\"19\",\"name\":\"我是一个测试的\"}"; String rs = wsesProxy.addJzzl(jsonData); System.out.println(rs); } } ``` 执行后的结果: ![image20210726233639501.webp](/download/0100f8eef9e9da454e1ab5b608699f439917.webp) login.login方法说明: //用户名,密码,固定值eas,EAS数据中心,固定值l2,0是Sql Server

单据新增WebService和Eclipse调用WebServcie.pdf


这个表是原来就有还是什么方法新建的,为啥直接就可以把数据写进去呀,是金蝶已经封装好了吗?


增加内容:

1:单据:增加明细文本备注;

2:json对应为:String jsonData = "{\"number\":\"080409\",\"description\":\"我是一个测试的\",\"billStatus\":\"1\",\"entry\":[{\"bz\":\"我是测试的\"},{\"bz\":\"我是第二个\"}]}";

3:webService对应代码修改为:

package com.kingdee.eas.custom.mylearn.app;


import java.util.Map;


import net.sf.json.JSONArray;

import net.sf.json.JSONObject;


import org.apache.log4j.Logger;



import com.kingdee.bos.BOSException;

import com.kingdee.bos.Context;

import com.kingdee.bos.util.BOSUuid;

import com.kingdee.eas.basedata.master.material.billStatus;

import com.kingdee.eas.common.EASBizException;

import com.kingdee.eas.custom.mylearn.MyLearnBillEntryFactory;

import com.kingdee.eas.custom.mylearn.MyLearnBillEntryInfo;

import com.kingdee.eas.custom.mylearn.MyLearnBillFactory;

import com.kingdee.eas.custom.mylearn.MyLearnBillInfo;


public class myLearnFacadeControllerBean extends AbstractmyLearnFacadeControllerBean

{

    private static Logger logger =

        Logger.getLogger("com.kingdee.eas.custom.mylearn.app.myLearnFacadeControllerBean");

    

    

    @SuppressWarnings("unchecked")

@Override

    protected String _addData(Context ctx, String json) throws BOSException,

    EASBizException {

   

    /***

    * 添加业务逻辑

    */

   

    JSONObject js = JSONObject.fromObject(json);

    Map<String,String> mapinfo = (Map<String,String>)js;

   

    MyLearnBillInfo myLearnBillInfo = new MyLearnBillInfo();

   

   

   

   

    myLearnBillInfo.setNumber(mapinfo.get("number"));

    myLearnBillInfo.setDescription(mapinfo.get("description"));

    myLearnBillInfo.setBillStatus(billStatus.getEnum(mapinfo.get("billStatus")));

   

   

   

       

    JSONArray jsonentry = JSONArray.fromObject(mapinfo.get("entry"));

   

   

    MyLearnBillEntryInfo myLearnBillEntryInfo = new MyLearnBillEntryInfo();

  

   

   

    MyLearnBillFactory.getLocalInstance(ctx).addnew(myLearnBillInfo);

     

    for(int i=0;i< jsonentry.size();i++){

    JSONObject jsonobentry = jsonentry.getJSONObject(i);

    myLearnBillEntryInfo.setParent(myLearnBillInfo);

    myLearnBillEntryInfo.setBz((String) jsonobentry.get("bz"));

    myLearnBillEntryInfo.setId(BOSUuid.create("4B33A3EE"));

   

    MyLearnBillEntryFactory.getLocalInstance(ctx).addnew(myLearnBillEntryInfo);

    }

   

   

    return "add success";

    }

}


4.可以实现单据分录生成。

Eclipse调用WebService(9)

## 下载login和接口对应的wsdl文件并将wsdl引入到Eclipse中:![image20210726232558358.webp](/download/0100c250b6f2491c43c7bc2b8595f01...
点击下载文档
分享:
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息