K3Cloud WebAPI 接口说明书_V2.0
修改记录
Ver. No |
发版日期 |
编制人 |
批准人 |
修改的章节号 |
V1.0 |
2016/8/9 |
|
|
初始版本 |
V2.0 |
2017/1/19 |
附录6 |
||
目 录
1. 概述
1.1. 目的
1.2. 范围
1.3. 适用对象
1.4. 参考资料
2. 问题与解决策略
3. 目标和约束
4. WebAPI架构
4.1. 采用的技术
4.1.1. Kingdee.BOS.WebApi.FormService.dll
4.1.2. Kingdee.BOS.WebApi.ServicesStub.dll
4.1.3. Kingdee.BOS.WebApi.Client.dll
4.1.4. 开发工具
5. WebAPI接口详细描述
5.1.1. 登陆验证接口
5.1.2. 查看表单数据接口
5.1.3. 保存表单数据接口
5.1.4. 批量保存表单数据接口
5.1.5. 提交表单数据接口
5.1.6. 审核表单数据接口
5.1.7. 反审核表单数据接口
5.1.8. 删除表单数据接口
5.1.9. 表单数据查询接口
5.1.10. 自定义WebAPI接口
6. 附录(集成相关知识分享)
为异构系统访问K/3Cloud系统数据提供通用的接口。
当企业规模逐渐增大时,作为支撑业务运营的IT建设也变得越来越重要,不过往往企业的IT建设过程中会发现某一家软件供应商基本不能完全覆盖企业所有的业务运营流程,这样的结果就是,企业上的IT系统很多很全,从ERP到HR、CRM、PDM、OA等,貌似所有的业务都覆盖到了,但实际上因为这些系统的不集成,而形成了企业很多新的信息孤岛,非常不利于企业的后续的管理和战略发展。K/3Cloud从现今和往后的发展趋势来看,也不可避免会遇到上述问题,毕竟企业经营的多样化,并不是所有的业务都能在K/3Cloud中完成,所以我们必须在产品架构上支持更好的与外部系统进行协同。
本文档适用于:
愿景 |
关注点 |
描述与示例 |
目标:
约束:
K/3 Cloud WebAPI是一种轻量级的、可维护的、可伸缩的 Web 服务。采用HTTP+JSON,也就是用RESTful的方式来开发。使用.NET Framework 4.0为开发平台,源代码使用C#编写。整个框架由三个组装件组成。
此组装件包含WebAPI主要接口的功能实现。部署在应用层服务器。
此组装件主要包含WebAPI接口定义,扩展接口定义以及登陆验证接口。部署在应用层服务器。
此组装件为WebAPI的客户端组件,封装了一些在异构系统客户端访问WebAPI的方法,适用于C#程序调用。由于它应用于异构系统客户端,所以此组装件需要拷贝到异构系统客户端环境中。非C#程序调用可以不用拷贝。
.Net FrameWork 4.0
Microsoft Visual Studio 2012
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
acctID |
账套Id,从管理中心数据库查询获得 |
必须 |
username |
用户登陆名 |
必须 |
password |
密码 |
必须 |
lcid |
语言id,选择哪种语言访问,参考:中文2052,英文1033,繁体3076 |
非必须,引用SDK组件辅助类调用则必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
LoginResultType |
//激活 |
管理员登陆可能出现返回-5的情况,这种情况在api验证时也可认为是允许的,具体可以根据实际情况来定。 var result = JObject.Parse(ret)["LoginResultType"].Value |
调用参考:
说明:下文中出现的client都为此处进行过登陆验证的ApiClient实例。
ApiClient client = new ApiClient("http://192.168.66.60/k3cloud/");
string dbId = "5756960b27b1aa"; //AotuTest117
bool bLogin = client.Login(dbId, "demo", "888888", 2052);
if (bLogin)
{
//todo:登陆成功处理业务
}
说明:以下HttpClient为自定义客户端调用辅助类,下文中所指HttpClient都表示这个类。
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
public class HttpClient
{
///
/// Seivice URL
///
public string Url { get; set; }
///
/// 内容
///
public string Content { get; set; }
///
/// Cookie,保证登录后,所有访问持有一个Cookie;
///
static CookieContainer Cookie = new CookieContainer();
///
/// HTTP访问
///
public string AsyncRequest()
{
HttpWebRequest httpRequest = HttpWebRequest.Create(Url) as HttpWebRequest;
httpRequest.Method = "POST";
httpRequest.ContentType = "application/json";
httpRequest.CookieContainer = Cookie;
httpRequest.Timeout = 1000 * 60 * 10;//10min
using (Stream reqStream = httpRequest.GetRequestStream())
{
JObject jObj = new JObject();
jObj.Add("format", 1);
jObj.Add("useragent", "ApiClient");
jObj.Add("rid", Guid.NewGuid().ToString().GetHashCode().ToString());
jObj.Add("parameters", Content);
jObj.Add("timestamp", DateTime.Now);
jObj.Add("v", "1.0");
string sContent = jObj.ToString();
var bytes = UnicodeEncoding.UTF8.GetBytes(sContent);
reqStream.Write(bytes, 0, bytes.Length);
reqStream.Flush();
}
using (var repStream = httpRequest.GetResponse().GetResponseStream())
{
using (var reader = new StreamReader(repStream))
{
return ValidateResult(reader.ReadToEnd());
}
}
}
private static string ValidateResult(string responseText)
{
if (responseText.StartsWith("response_error:"))
{
return responseText.TrimStart("response_error:".ToCharArray());
}
return responseText;
}
}
登陆验证参考:
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc";
List
Parameters.Add("558cbb01bfc79b");//帐套Id
Parameters.Add("Administrator");//用户名
Parameters.Add("888888");//密码
Parameters.Add(2052);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var iResult = JObject.Parse(httpClient.AsyncRequest())["LoginResultType"].Value
if (iResult == 1){
//todo:验证成功,处理业务
}
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"IV_SALESIC"//表示发票 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。格式参考:"{\"CreateOrgId\":0,\"Id\":0,\"Number\":\"SVINV00000003\"}" |
CreateOrgId:非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 |
操作是否成功,如果失败,具体失败原因 |
Result |
单据数据包 |
单据完整数据内容 |
调用参考:
string sJson = "{\"Number\":\"SVINV00000003\"}";
var result = client.Execute
new object[] { "IV_SALESIC", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc";
List
//业务对象Id
String formid = "IV_SALESIC";//发票
Parameters.Add(formid);
//Json字串
string data = "{\"Number\":\"SVINV00000003\"}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,数据格式参考以币别为例:"{\"Creator\":\"\", |
Creator:非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
调用参考:
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
//业务对象Id
string sFormId = "SAL_OUTSTOCK"; //销售出库单
//Model字串
string sContent = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\":" + "{\"FID\":\"0\",\"FStockOrgId\":{\"FNumber\":\"210\"},\"FBillTypeID\":{\"FNumber\":\"XSCKD01_SYS\"},\"FBillNo\":\"CSDGBC21002\",\"FCustomerID\":{\"FNumber\":\"CUST0073\"},\"SubHeadEntity\":{\"FExchangeRate\":6.51},\"FEntity\":[{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK002\"},\"FRealQty\":324,\"FBaseUnitQty\":324},{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK004\"},\"FRealQty\":220,\"FBaseUnitQty\":220}]]}}";
object[] saveInfo = new object[]
{
sFormId,
sContent
};
//调用保存接口
var ret = client.Execute
以下示例说明如何更新单据的表体信息:
更新内码为100017的单据,新增两行表体数据,原有100024和100025行数据保留,如果源单中还有其他分录则删除。
string sFormId = "STK_MISCELLANEOUS";//其他入库单
string sContent = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\":{\"FID\":\"100017\",\"FEntity\":[{\"FEntryID\":\"100024\"},{\"FEntryID\":\"100025\"}," + "{\"FMATERIALID\":{\"FNumber\":\"A.0060480933\"},\"FUnitID\":{\"FNumber\":\"03\"},\"FSTOCKID\":{\"FNumber\":\"PRTSH\"},\"FQty\":\"200\",\"FBASEQTY\":\"200\",\"FPlanAmount\":\"132856\",\"FBASEUNITID\":{\"FNumber\":\"03\"},\"FEntryNOTE\":\"2015-7-29\",\"FAmount\":\"132856\",\"FPRICE\":\"664.28\",\"FEntrySelfA9725\":\"2015072802\",\"FEntrySelfA9733\":\"19881\",\"FEntrySelfA9734\":\"2015-6-3\",\"FEntrySelfA9737\":\"200\",\"FEntrySelfA9740\":\"0\",\"FEntrySelfA9738\":\"1\",\"FEntrySelfA9739\":\"2\",\"FEntrySelfA9735\":\"664.28\"}," +
"{\"FMATERIALID\":{\"FNumber\":\"A.0060480933"},\"FUnitID\":{\"FNumber\":\"03\"},\"FSTOCKID\":{\"FNumber\":\"PRTSH\"},\"FQty\":\"200\",\"FBASEQTY\":\"200\",\"FPlanAmount\":\"132856\",\"FBASEUNITID\":{\"FNumber\":\"03\"},\"FEntryNOTE\":\"2015-7-29\",\"FAmount\":\"132856\",\"FPRICE\":\"664.28\",\"FEntrySelfA9725\":\"2015072802\",\"FEntrySelfA9733\":\"19881\",\"FEntrySelfA9734\":\"2015-6-3\",\"FEntrySelfA9737\":\"200\",\"FEntrySelfA9740\":\"0\",\"FEntrySelfA9738\":\"1\",\"FEntrySelfA9739\":\"2\",\"FEntrySelfA9735\":\"664.28\"}]}}";
object[] saveInfo = new object[]
{
sFormId,
sContent
};
//调用保存接口
var ret=
client.Execute
2)无引用组件示例(不引用金蝶的组件):
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc";
List
//业务对象Id
String formid = "SAL_OUTSTOCK";//销售出库为例
Parameters.Add(formid);
//Json字串
string data = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\":" + "{\"FID\":\"0\",\"FStockOrgId\":{\"FNumber\":\"210\"},\"FBillTypeID\":{\"FNumber\":\"XSCKD01_SYS\"},\"FBillNo\":\"CSDGBC21002\",\"FCustomerID\":{\"FNumber\":\"CUST0073\"},\"SubHeadEntity\":{\"FExchangeRate\":6.51},\"FEntity\":[{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK002\"},\"FRealQty\":324,\"FBaseUnitQty\":324},{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK004\"},\"FRealQty\":220,\"FBaseUnitQty\":220}]]}}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.BatchSave.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"SAL_SaleOrder"//表示销售订单 |
必须 |
data |
数据包,格式参考以销售订单为例: "{\"NeedUpDateFields\":[],\"BatchCount\":\"2\", \"Model\":[{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931\"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"}, \"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931\"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]}]}" |
BatchCount:非必须。此参数主要用于优化性能,当传入的单据数据量较大时,可以设定此参数的并行分批执行次数。例如传入100张单据数据,此参数设定为10,则表示在k3cloud系统中,以10个单据为一批,分10批,同时并发保存,提升效率。 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
调用参考:
string sFormId = "SAL_SaleOrder";//销售订单为例
string sContent = "{\"NeedUpDateFields\":[],\"BatchCount\":\"2\",\"Model\":[{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]}]}";
object[] saveInfo = new object[]
{
sFormId,
sContent
};
var ret =
client.Execute
2)无引用组件示例(不引用金蝶的组件):
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.BatchSave.common.kdsvc";
List
//业务对象Id
String formid = "SAL_SaleOrder";//销售订单为例
Parameters.Add(formid);
//Json字串
string data = "{\"NeedUpDateFields\":[],\"BatchCount\":\"2\",\"Model\":[{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]}]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
调用参考:
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
new object[] { "BD_Currency", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
new object[] { "BD_Currency", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Delete.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
new object[] { "BD_Currency", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Delete.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
data |
数据包格式参考: "{\"FormId\":\"PUR_PurchaseOrder\",\"TopRowCount\":0,\"Limit\":10,\"StartRow\":0,\"FilterString\":\"FMaterialId.FNumber='HG_TEST'\",\"OrderString\":\"FID ASC\",\"FieldKeys\":\"FID,FSupplierId,FMaterialId,FMaterialId.FNumber,FMaterialName\"}" |
FormId:查询表单元数据唯一标识 TopRowCount: 最多允许查询的数量,0或者不要此属性表示不限制 Limit:分页取数每页允许获取的数据,最大不能超过2000 StartRow:分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20 FilterString:过滤条件 OrderString:排序条件 FieldKeys:待查询表单的字段列表 |
返回参数:
调用参考:
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
object[] paramInfo = new object[]
{
"{\"FormId\":\"PUR_PurchaseOrder\","+// 采购订单formid
"\"TopRowCount\":0,"+// 最多允许查询的数量,0或者不要此属性表示不限制
"\"Limit\":10,"+// 分页取数每页允许获取的数据,最大不能超过2000
"\"StartRow\":0,"+// 分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
"\"FilterString\":\"FMaterialId.FNumber='HG_TEST'\","+// 过滤条件
"\"OrderString\":\"FID ASC\","+// 排序条件 "\"FieldKeys\":\"FID,FSupplierId,FMaterialId,FMaterialId.FNumber,FMaterialName\"}"// 获取采购订单数据参数,内码,供应商id,物料id,物料编码,物料名称
};
//调用查询接口
List> ret = client.Execute
>>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery", paramInfo);
if (ret != null && ret.Count > 0)
{
// TODO:
}
2)无引用组件示例(不引用金蝶的组件):
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
List
//Json字串
string data = "{\"FormId\":\"PUR_PurchaseOrder\",\"TopRowCount\":0,\"Limit\":10,\"StartRow\":0,\"FilterString\":\"FMaterialId.FNumber='HG_TEST'\",\"OrderString\":\"FID ASC\",\"FieldKeys\":\"FID,FSupplierId,FMaterialId,FMaterialId.FNumber,FMaterialName\"}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/接口命名空间.接口实现类名.方法,组件名.common.kdsvc
例如:
"http://192.168.66.60/k3cloud/ApiServiceTest.AAA.CustomBusinessService.ExecuteService,ApiServiceTest.AAA.common.kdsvc"
需要注意的是,自定义webapi接口服务地址中比其他标准接口地址多了一个组件名,如果需要和其他其他标准接口保持一致,则二开自定义的webapi接口命名空间必须以.ServicesStub结尾,例如以下示例自定义接口则其服务地址可以参考如下格式:
"http://192.168.66.60/k3cloud/Kingdee.K3Erp.WebAPI.ServiceExtend.ServicesStub.CustomBusinessService ExecuteService.common.kdsvc"
/*
* 服务需要引用组件如下
* Kingdee.BOS.dll、
Kingdee.BOS.ServiceFacade.KDServiceFx.dll、
Kingdee.BOS.WebApi.ServicesStub.dll
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.ServiceFacade.KDServiceFx;
using Kingdee.BOS.WebApi.ServicesStub;
using Kingdee.BOS.JSON;
namespace Kingdee.K3Erp.WebAPI.ServiceExtend.ServicesStub
{
public class CustomBusinessService : AbstractWebApiBusinessService
{
public CustomBusinessService(KDServiceContext context)
: base(context)
{ }
public JSONArray ExecuteService(string parameter)
{
JSONArray jsonArray = new JSONArray();
jsonArray.Add("Hello World");
return jsonArray;
}
}
}
接口参数:
自定义。
返回参数:
自定义。
调用参考:
// 此接口为K3Cloud自定义接口,命名控件及类名仅供参考。
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Metadata.DataEntity;
using Kingdee.BOS.ServiceHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ApiServiceTest.AAA
{
///
///
///
public class CustomBusinessService : Kingdee.BOS.WebApi.ServicesStub.AbstractWebApiBusinessService
{
public CustomBusinessService(Kingdee.BOS.ServiceFacade.KDServiceFx.KDServiceContext context)
: base(context)
{ }
///
/// 执行服务,根据参数来处理自己的业务并返回结果
///
///
///
///
public JSONArray ExecuteService(string parameter)
{
// TODO:在此方法中处理业务,可以引用Kingdee现有接口,根据传入的参数来实现自己的业务逻辑,
// 例如查询数据、单据转换、甚至数据同步等都可以
// 以下为查询币别信息的示例代码
// 构造查询参数
QueryBuilderParemeter para = new QueryBuilderParemeter()
{
// 查询表单,测试用例中直接传入了“BD_Currency”
FormId = parameter,
// 需要查询币别主键、币别名称等信息,此处用字段的标识来构造
SelectItems = SelectorItemInfo.CreateItems("FCURRENCYID,FName"),
};
// 调用查询接口
DynamicObjectCollection list = QueryServiceHelper.GetDynamicObjectCollection(this.KDContext.Session.AppContext, para);
// 返回结果类型可以自定义
// 如果第三方系统不想引用BOS其他组件的,可以使用json字符串、List、Dictionary等类型做为返回结果
// 此处示例代码使用 BOS定义的类型JSONArray
JSONArray jsonArray = new JSONArray();
foreach (DynamicObject dynamicObject in list)
{
jsonArray.Add(ConvertDynamicObject2Json(dynamicObject));
}
return jsonArray;
}
///
/// 自定义服务接口
///
///
///
///
public bool UpdateData(string parameter,string formId)
{
return true;
}
private JSONObject ConvertDynamicObject2Json(DynamicObject dynamicObject)
{
DynamicPropertyCollection dynamicPropertyCollection = dynamicObject.DynamicObjectType.Properties;
JSONObject obj = new JSONObject();
foreach (DynamicProperty property in dynamicPropertyCollection)
{
obj.Put(property.Name, dynamicObject[property.Name]);
}
return obj;
}
}
}
var responseOut = client.Execute
HttpClient httpClient = new HttpClient();
httpClient.Url = string.Concat("http://192.168.66.60/k3cloud/ApiServiceTest.AAA.CustomBusinessService.ExecuteService,ApiServiceTest.AAA.common.kdsvc");
List
Parameters.Add("BD_Currency");
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var responseOut = httpClient.AsyncRequest();
在6.1最新补丁已经集成了webapi在线测试功能,通过管理员登录,选择webapi sdk,可以直接进行各单据接口的模拟测试,并提供了完整的接口参数数据供二开参考和使用。
Web API方式相关链接置顶:
.net
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
Java
K/3 Cloud Web API销售订单Java完整示例【分享】
http://club.kisdee.com/forum.php?mod=viewthread&tid=959863
php
K/3 Cloud Web API销售出库单PHP完整示例【分享】
K/3 Cloud Web API销售出库单PHP完整示例【分享】
WebApi之新接口推广
WebApi之新接口推广
K/3 Cloud WebAPI接口说明文档
欢迎访问金蝶云社区
WebAPI【财务凭证】核算维度赋值【分享】
WebAPI【财务凭证】核算维度赋值【分享】
WebAPI查询表单数据接口示例
金蝶社区
WebAPI批量保存接口示例
金蝶社区
小技巧 - 如何逐步构建采购订单Web API保存接口参数
小技巧 - 如何逐步构建采购订单Web API保存接口参数
K3Cloud系统集成实现下推单据转换调用【分享】
K3Cloud系统集成实现下推单据转换调用【分享】
K/3Cloud WebAPI 调用任意操作实现方案【分享】
K/3Cloud WebAPI 调用任意操作实现方案【分享】
注意:WebAPI方式调用是不需要发布站点的,需要发布站点的就不是WebAPI方式
——————置顶完毕 分割线————————
发布SI站点:
开单贴,K/3Cloud系统集成配置及示例
开单贴,K/3Cloud系统集成配置及示例
发布SI站点出错解决:
【已解决】5.0 集成站点发布失败!!!
【已解决】5.0 集成站点发布失败!!!
SI的Web Service方式:
Web Service方式 【销售普通发票】保存【分享】
Web Service方式 【销售普通发票】保存【分享】
Web Service 不引用SDK方式 新增【用户】 【分享】
Web Service 不引用SDK方式 新增【用户】 【分享】
SI的Json格式:
K3Cloud系统集成Json方式调用【分享】
K3Cloud系统集成Json方式调用【分享】
采用Json方式集成调用批量查询数据【分享】
采用Json方式集成调用批量查询数据【分享】
系统集成构造Json格式包含子单据体示例【分享】
系统集成构造Json格式包含子单据体示例【分享】
Web Service 上传附件Json格式【分享】
Web Service 上传附件Json格式【分享】
Web API方式:
K/3 Cloud WebAPI接口说明文档
欢迎访问金蝶云社区
WebApi之新接口推广
WebApi之新接口推广
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
WebAPI【财务凭证】核算维度赋值【分享】
http://club.kisdee.com/forum.php?mod=viewthread&tid=989427
PHP方式调用:
Cloud系统集成 PHP完整调用示例【分享】
Cloud系统集成 PHP完整调用示例【分享】
K/3 Cloud Web API销售出库单PHP完整示例【分享】
K/3 Cloud Web API销售出库单PHP完整示例【分享】
Java方式调用:
Cloud系统集成 Java完整调用示例【分享】
Cloud系统集成 Java完整调用示例【分享】
K/3 Cloud Web API集成开发Java完整示例【分享】
K/3 Cloud Web API集成开发Java完整示例【分享】
另:
基于Cloud代理组件方式集成:
基于.net Framework4.0 第三方通过Cloud代理组件集成开发【分享】
基于.net Framework4.0 第三方通过Cloud代理组件集成开发【分享】
硬件集成:
【分享】客制化控件插件实现客户端设备集成
【分享】客制化控件插件实现客户端设备集成
K3Cloud WebAPI 接口说明书_V2.0
修改记录
Ver. No |
发版日期 |
编制人 |
批准人 |
修改的章节号 |
V1.0 |
2016/8/9 |
刘兵 |
赖碧云 |
初始版本 |
V2.0 |
2017/1/19 |
刘兵 |
赖碧云 |
附录6 |
目 录
1. 概述
1.1. 目的
1.2. 范围
1.3. 适用对象
1.4. 参考资料
2. 问题与解决策略
3. 目标和约束
4. WebAPI架构
4.1. 采用的技术
4.1.1. Kingdee.BOS.WebApi.FormService.dll
4.1.2. Kingdee.BOS.WebApi.ServicesStub.dll
4.1.3. Kingdee.BOS.WebApi.Client.dll
4.1.4. 开发工具
5. WebAPI接口详细描述
5.1.1. 登陆验证接口
5.1.2. 查看表单数据接口
5.1.3. 保存表单数据接口
5.1.4. 批量保存表单数据接口
5.1.5. 提交表单数据接口
5.1.6. 审核表单数据接口
5.1.7. 反审核表单数据接口
5.1.8. 删除表单数据接口
5.1.9. 表单数据查询接口
5.1.10. 自定义WebAPI接口
6. 附录(集成相关知识分享)
为异构系统访问K/3Cloud系统数据提供通用的接口。
当企业规模逐渐增大时,作为支撑业务运营的IT建设也变得越来越重要,不过往往企业的IT建设过程中会发现某一家软件供应商基本不能完全覆盖企业所有的业务运营流程,这样的结果就是,企业上的IT系统很多很全,从ERP到HR、CRM、PDM、OA等,貌似所有的业务都覆盖到了,但实际上因为这些系统的不集成,而形成了企业很多新的信息孤岛,非常不利于企业的后续的管理和战略发展。K/3Cloud从现今和往后的发展趋势来看,也不可避免会遇到上述问题,毕竟企业经营的多样化,并不是所有的业务都能在K/3Cloud中完成,所以我们必须在产品架构上支持更好的与外部系统进行协同。
本文档适用于:
愿景 |
关注点 |
描述与示例 |
目标:
约束:
K/3 Cloud WebAPI是一种轻量级的、可维护的、可伸缩的 Web 服务。采用HTTP+JSON,也就是用RESTful的方式来开发。使用.NET Framework 4.0为开发平台,源代码使用C#编写。整个框架由三个组装件组成。
此组装件包含WebAPI主要接口的功能实现。部署在应用层服务器。
此组装件主要包含WebAPI接口定义,扩展接口定义以及登陆验证接口。部署在应用层服务器。
此组装件为WebAPI的客户端组件,封装了一些在异构系统客户端访问WebAPI的方法,适用于C#程序调用。由于它应用于异构系统客户端,所以此组装件需要拷贝到异构系统客户端环境中。非C#程序调用可以不用拷贝。
.Net FrameWork 4.0
Microsoft Visual Studio 2012
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
acctID |
账套Id,从管理中心数据库查询获得 |
必须 |
username |
用户登陆名 |
必须 |
password |
密码 |
必须 |
lcid |
语言id,选择哪种语言访问,参考:中文2052,英文1033,繁体3076 |
非必须,引用SDK组件辅助类调用则必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
LoginResultType |
//激活 |
管理员登陆可能出现返回-5的情况,这种情况在api验证时也可认为是允许的,具体可以根据实际情况来定。 var result = JObject.Parse(ret)["LoginResultType"].Value |
调用参考:
说明:下文中出现的client都为此处进行过登陆验证的ApiClient实例。
ApiClient client = new ApiClient("http://192.168.66.60/k3cloud/");
string dbId = "5756960b27b1aa"; //AotuTest117
bool bLogin = client.Login(dbId, "demo", "888888", 2052);
if (bLogin)
{
//todo:登陆成功处理业务
}
说明:以下HttpClient为自定义客户端调用辅助类,下文中所指HttpClient都表示这个类。
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
public class HttpClient
{
///
/// Seivice URL
///
public string Url { get; set; }
///
/// 内容
///
public string Content { get; set; }
///
/// Cookie,保证登录后,所有访问持有一个Cookie;
///
static CookieContainer Cookie = new CookieContainer();
///
/// HTTP访问
///
public string AsyncRequest()
{
HttpWebRequest httpRequest = HttpWebRequest.Create(Url) as HttpWebRequest;
httpRequest.Method = "POST";
httpRequest.ContentType = "application/json";
httpRequest.CookieContainer = Cookie;
httpRequest.Timeout = 1000 * 60 * 10;//10min
using (Stream reqStream = httpRequest.GetRequestStream())
{
JObject jObj = new JObject();
jObj.Add("format", 1);
jObj.Add("useragent", "ApiClient");
jObj.Add("rid", Guid.NewGuid().ToString().GetHashCode().ToString());
jObj.Add("parameters", Content);
jObj.Add("timestamp", DateTime.Now);
jObj.Add("v", "1.0");
string sContent = jObj.ToString();
var bytes = UnicodeEncoding.UTF8.GetBytes(sContent);
reqStream.Write(bytes, 0, bytes.Length);
reqStream.Flush();
}
using (var repStream = httpRequest.GetResponse().GetResponseStream())
{
using (var reader = new StreamReader(repStream))
{
return ValidateResult(reader.ReadToEnd());
}
}
}
private static string ValidateResult(string responseText)
{
if (responseText.StartsWith("response_error:"))
{
return responseText.TrimStart("response_error:".ToCharArray());
}
return responseText;
}
}
登陆验证参考:
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc";
List
Parameters.Add("558cbb01bfc79b");//帐套Id
Parameters.Add("Administrator");//用户名
Parameters.Add("888888");//密码
Parameters.Add(2052);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var iResult = JObject.Parse(httpClient.AsyncRequest())["LoginResultType"].Value
if (iResult == 1){
//todo:验证成功,处理业务
}
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"IV_SALESIC"//表示发票 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。格式参考:"{\"CreateOrgId\":0,\"Id\":0,\"Number\":\"SVINV00000003\"}" |
CreateOrgId:非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 |
操作是否成功,如果失败,具体失败原因 |
Result |
单据数据包 |
单据完整数据内容 |
调用参考:
string sJson = "{\"Number\":\"SVINV00000003\"}";
var result = client.Execute
new object[] { "IV_SALESIC", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc";
List
//业务对象Id
String formid = "IV_SALESIC";//发票
Parameters.Add(formid);
//Json字串
string data = "{\"Number\":\"SVINV00000003\"}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,数据格式参考以币别为例:"{\"Creator\":\"\", |
Creator:非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
调用参考:
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
//业务对象Id
string sFormId = "SAL_OUTSTOCK"; //销售出库单
//Model字串
string sContent = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\":" + "{\"FID\":\"0\",\"FStockOrgId\":{\"FNumber\":\"210\"},\"FBillTypeID\":{\"FNumber\":\"XSCKD01_SYS\"},\"FBillNo\":\"CSDGBC21002\",\"FCustomerID\":{\"FNumber\":\"CUST0073\"},\"SubHeadEntity\":{\"FExchangeRate\":6.51},\"FEntity\":[{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK002\"},\"FRealQty\":324,\"FBaseUnitQty\":324},{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK004\"},\"FRealQty\":220,\"FBaseUnitQty\":220}]]}}";
object[] saveInfo = new object[]
{
sFormId,
sContent
};
//调用保存接口
var ret = client.Execute
以下示例说明如何更新单据的表体信息:
更新内码为100017的单据,新增两行表体数据,原有100024和100025行数据保留,如果源单中还有其他分录则删除。
string sFormId = "STK_MISCELLANEOUS";//其他入库单
string sContent = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\":{\"FID\":\"100017\",\"FEntity\":[{\"FEntryID\":\"100024\"},{\"FEntryID\":\"100025\"}," + "{\"FMATERIALID\":{\"FNumber\":\"A.0060480933\"},\"FUnitID\":{\"FNumber\":\"03\"},\"FSTOCKID\":{\"FNumber\":\"PRTSH\"},\"FQty\":\"200\",\"FBASEQTY\":\"200\",\"FPlanAmount\":\"132856\",\"FBASEUNITID\":{\"FNumber\":\"03\"},\"FEntryNOTE\":\"2015-7-29\",\"FAmount\":\"132856\",\"FPRICE\":\"664.28\",\"FEntrySelfA9725\":\"2015072802\",\"FEntrySelfA9733\":\"19881\",\"FEntrySelfA9734\":\"2015-6-3\",\"FEntrySelfA9737\":\"200\",\"FEntrySelfA9740\":\"0\",\"FEntrySelfA9738\":\"1\",\"FEntrySelfA9739\":\"2\",\"FEntrySelfA9735\":\"664.28\"}," +
"{\"FMATERIALID\":{\"FNumber\":\"A.0060480933"},\"FUnitID\":{\"FNumber\":\"03\"},\"FSTOCKID\":{\"FNumber\":\"PRTSH\"},\"FQty\":\"200\",\"FBASEQTY\":\"200\",\"FPlanAmount\":\"132856\",\"FBASEUNITID\":{\"FNumber\":\"03\"},\"FEntryNOTE\":\"2015-7-29\",\"FAmount\":\"132856\",\"FPRICE\":\"664.28\",\"FEntrySelfA9725\":\"2015072802\",\"FEntrySelfA9733\":\"19881\",\"FEntrySelfA9734\":\"2015-6-3\",\"FEntrySelfA9737\":\"200\",\"FEntrySelfA9740\":\"0\",\"FEntrySelfA9738\":\"1\",\"FEntrySelfA9739\":\"2\",\"FEntrySelfA9735\":\"664.28\"}]}}";
object[] saveInfo = new object[]
{
sFormId,
sContent
};
//调用保存接口
var ret=
client.Execute
2)无引用组件示例(不引用金蝶的组件):
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc";
List
//业务对象Id
String formid = "SAL_OUTSTOCK";//销售出库为例
Parameters.Add(formid);
//Json字串
string data = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"Model\":" + "{\"FID\":\"0\",\"FStockOrgId\":{\"FNumber\":\"210\"},\"FBillTypeID\":{\"FNumber\":\"XSCKD01_SYS\"},\"FBillNo\":\"CSDGBC21002\",\"FCustomerID\":{\"FNumber\":\"CUST0073\"},\"SubHeadEntity\":{\"FExchangeRate\":6.51},\"FEntity\":[{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK002\"},\"FRealQty\":324,\"FBaseUnitQty\":324},{\"FEntryID\":\"0\",\"FMATERIALID\":{\"FNumber\":\"03.001\"},\"FStockID\":{\"FNumber\":\"CK004\"},\"FRealQty\":220,\"FBaseUnitQty\":220}]]}}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.BatchSave.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"SAL_SaleOrder"//表示销售订单 |
必须 |
data |
数据包,格式参考以销售订单为例: "{\"NeedUpDateFields\":[],\"BatchCount\":\"2\", \"Model\":[{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931\"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"}, \"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931\"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]}]}" |
BatchCount:非必须。此参数主要用于优化性能,当传入的单据数据量较大时,可以设定此参数的并行分批执行次数。例如传入100张单据数据,此参数设定为10,则表示在k3cloud系统中,以10个单据为一批,分10批,同时并发保存,提升效率。 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
调用参考:
string sFormId = "SAL_SaleOrder";//销售订单为例
string sContent = "{\"NeedUpDateFields\":[],\"BatchCount\":\"2\",\"Model\":[{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]}]}";
object[] saveInfo = new object[]
{
sFormId,
sContent
};
var ret =
client.Execute
2)无引用组件示例(不引用金蝶的组件):
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.BatchSave.common.kdsvc";
List
//业务对象Id
String formid = "SAL_SaleOrder";//销售订单为例
Parameters.Add(formid);
//Json字串
string data = "{\"NeedUpDateFields\":[],\"BatchCount\":\"2\",\"Model\":[{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]},{\"FID\":\"0\",\"FBILLTYPEID\":{\"FNumber\":\"XSDD01_SYS\"},\"FSaleOrgId\":{\"FNumber\":\"NCIC\"},\"FSaleDeptId\":{\"FNumber\":\"01.A13\"},\"FCustId\":{\"FNumber\":\"500\"},\"FDATE\":\"2016/2/23\",\"FSettleCurrId\":{\"FNumber\":\"RMB\"},\"FSalerId\":{\"FNumber\":\"B027\"},\"FBusinessType\":\"NORMAL\",\"FSaleOrderFinance\":{\"FEXCHANGETYPE\":{\"FNumber\":\"NCIC\"},\"FExchangeRate\":\"1\"},\"FSaleOrderEntry\":[{\"FMATERIALID\":{\"FNumber\":\"A.0060480931 \"},\"FUNITID\":{\"FNumber\":\"03\"},\"FQty\":\"1\",\"FTaxPrice\":\"100\",\"FEntryTaxRate\":\"17.00\"}]}]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
调用参考:
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
new object[] { "BD_Currency", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
new object[] { "BD_Currency", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Delete.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
formid |
表单Id,格式参考:"BD_Currency"//表示币别 |
必须 |
data |
数据包,Number表示单据编号或者基础资料编码,Id为主键,CreateOrgId为创建组织Id。数据格式参考以币别为例:"{\"CreateOrgId\":0,\"UseOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}" |
CreateOrgId:创建组织Id,非必须 UseOrgId:使用组织Id,非必须 |
返回参数:
参数列表 |
参数含义 |
备注 |
ResponseStatus |
操作状态 "IsSuccess":false, "Errors":[{"FieldName":"", "Message":"","DIndex":0}], "SuccessEntitys":[{"Id":"","Number":"","DIndex":0}], "SuccessMessages":[{"FieldName":"","Message":"","DIndex":0}]} |
IsSuccess:操作是否成功, |
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
string sJson = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
var result = client.Execute
new object[] { "BD_Currency", sJson });
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Delete.common.kdsvc";
List
//业务对象Id
String formid = "BD_Currency";//币别为例
Parameters.Add(formid);
//Json字串
string data = "{\"CreateOrgId\":0,\"Numbers\":[\"PRE002\",\"PRE006\"]}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc
接口参数:
参数列表 |
参数含义 |
备注 |
data |
数据包格式参考: "{\"FormId\":\"PUR_PurchaseOrder\",\"TopRowCount\":0,\"Limit\":10,\"StartRow\":0,\"FilterString\":\"FMaterialId.FNumber='HG_TEST'\",\"OrderString\":\"FID ASC\",\"FieldKeys\":\"FID,FSupplierId,FMaterialId,FMaterialId.FNumber,FMaterialName\"}" |
FormId:查询表单元数据唯一标识 TopRowCount: 最多允许查询的数量,0或者不要此属性表示不限制 Limit:分页取数每页允许获取的数据,最大不能超过2000 StartRow:分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20 FilterString:过滤条件 OrderString:排序条件 FieldKeys:待查询表单的字段列表 |
返回参数:
调用参考:
1)SDK辅助类示例(引用Kingdee.BOS.WebAPI.Client.dll):
object[] paramInfo = new object[]
{
"{\"FormId\":\"PUR_PurchaseOrder\","+// 采购订单formid
"\"TopRowCount\":0,"+// 最多允许查询的数量,0或者不要此属性表示不限制
"\"Limit\":10,"+// 分页取数每页允许获取的数据,最大不能超过2000
"\"StartRow\":0,"+// 分页取数开始行索引,从0开始,例如每页10行数据,第2页开始是10,第3页开始是20
"\"FilterString\":\"FMaterialId.FNumber='HG_TEST'\","+// 过滤条件
"\"OrderString\":\"FID ASC\","+// 排序条件 "\"FieldKeys\":\"FID,FSupplierId,FMaterialId,FMaterialId.FNumber,FMaterialName\"}"// 获取采购订单数据参数,内码,供应商id,物料id,物料编码,物料名称
};
//调用查询接口
List> ret = client.Execute
>>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery", paramInfo);
if (ret != null && ret.Count > 0)
{
// TODO:
}
2)无引用组件示例(不引用金蝶的组件):
HttpClient httpClient = new HttpClient();
httpClient.Url = "http://192.168.66.60/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
List
//Json字串
string data = "{\"FormId\":\"PUR_PurchaseOrder\",\"TopRowCount\":0,\"Limit\":10,\"StartRow\":0,\"FilterString\":\"FMaterialId.FNumber='HG_TEST'\",\"OrderString\":\"FID ASC\",\"FieldKeys\":\"FID,FSupplierId,FMaterialId,FMaterialId.FNumber,FMaterialName\"}";
Parameters.Add(data);
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var result = httpClient.AsyncRequest();
服务地址:
http://ServerIp/K3Cloud/接口命名空间.接口实现类名.方法,组件名.common.kdsvc
例如:
"http://192.168.66.60/k3cloud/ApiServiceTest.AAA.CustomBusinessService.ExecuteService,ApiServiceTest.AAA.common.kdsvc"
需要注意的是,自定义webapi接口服务地址中比其他标准接口地址多了一个组件名,如果需要和其他其他标准接口保持一致,则二开自定义的webapi接口命名空间必须以.ServicesStub结尾,例如以下示例自定义接口则其服务地址可以参考如下格式:
"http://192.168.66.60/k3cloud/Kingdee.K3Erp.WebAPI.ServiceExtend.ServicesStub.CustomBusinessService ExecuteService.common.kdsvc"
/*
* 服务需要引用组件如下
* Kingdee.BOS.dll、
Kingdee.BOS.ServiceFacade.KDServiceFx.dll、
Kingdee.BOS.WebApi.ServicesStub.dll
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.ServiceFacade.KDServiceFx;
using Kingdee.BOS.WebApi.ServicesStub;
using Kingdee.BOS.JSON;
namespace Kingdee.K3Erp.WebAPI.ServiceExtend.ServicesStub
{
public class CustomBusinessService : AbstractWebApiBusinessService
{
public CustomBusinessService(KDServiceContext context)
: base(context)
{ }
public JSONArray ExecuteService(string parameter)
{
JSONArray jsonArray = new JSONArray();
jsonArray.Add("Hello World");
return jsonArray;
}
}
}
接口参数:
自定义。
返回参数:
自定义。
调用参考:
// 此接口为K3Cloud自定义接口,命名控件及类名仅供参考。
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Metadata.DataEntity;
using Kingdee.BOS.ServiceHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ApiServiceTest.AAA
{
///
///
///
public class CustomBusinessService : Kingdee.BOS.WebApi.ServicesStub.AbstractWebApiBusinessService
{
public CustomBusinessService(Kingdee.BOS.ServiceFacade.KDServiceFx.KDServiceContext context)
: base(context)
{ }
///
/// 执行服务,根据参数来处理自己的业务并返回结果
///
///
///
///
public JSONArray ExecuteService(string parameter)
{
// TODO:在此方法中处理业务,可以引用Kingdee现有接口,根据传入的参数来实现自己的业务逻辑,
// 例如查询数据、单据转换、甚至数据同步等都可以
// 以下为查询币别信息的示例代码
// 构造查询参数
QueryBuilderParemeter para = new QueryBuilderParemeter()
{
// 查询表单,测试用例中直接传入了“BD_Currency”
FormId = parameter,
// 需要查询币别主键、币别名称等信息,此处用字段的标识来构造
SelectItems = SelectorItemInfo.CreateItems("FCURRENCYID,FName"),
};
// 调用查询接口
DynamicObjectCollection list = QueryServiceHelper.GetDynamicObjectCollection(this.KDContext.Session.AppContext, para);
// 返回结果类型可以自定义
// 如果第三方系统不想引用BOS其他组件的,可以使用json字符串、List、Dictionary等类型做为返回结果
// 此处示例代码使用 BOS定义的类型JSONArray
JSONArray jsonArray = new JSONArray();
foreach (DynamicObject dynamicObject in list)
{
jsonArray.Add(ConvertDynamicObject2Json(dynamicObject));
}
return jsonArray;
}
///
/// 自定义服务接口
///
///
///
///
public bool UpdateData(string parameter,string formId)
{
return true;
}
private JSONObject ConvertDynamicObject2Json(DynamicObject dynamicObject)
{
DynamicPropertyCollection dynamicPropertyCollection = dynamicObject.DynamicObjectType.Properties;
JSONObject obj = new JSONObject();
foreach (DynamicProperty property in dynamicPropertyCollection)
{
obj.Put(property.Name, dynamicObject[property.Name]);
}
return obj;
}
}
}
var responseOut = client.Execute
HttpClient httpClient = new HttpClient();
httpClient.Url = string.Concat("http://192.168.66.60/k3cloud/ApiServiceTest.AAA.CustomBusinessService.ExecuteService,ApiServiceTest.AAA.common.kdsvc");
List
Parameters.Add("BD_Currency");
httpClient.Content = JsonConvert.SerializeObject(Parameters);
var responseOut = httpClient.AsyncRequest();
在6.1最新补丁已经集成了webapi在线测试功能,通过管理员登录,选择webapi sdk,可以直接进行各单据接口的模拟测试,并提供了完整的接口参数数据供二开参考和使用。
Web API方式相关链接置顶:
.net
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
Java
K/3 Cloud Web API销售订单Java完整示例【分享】
K/3 Cloud Web API集成开发Java完整示例【分享】
php
K/3 Cloud Web API销售出库单PHP完整示例【分享】
K/3 Cloud Web API销售出库单PHP完整示例【分享】
WebApi之新接口推广
WebApi之新接口推广
K/3 Cloud WebAPI接口说明文档
欢迎访问金蝶云社区
WebAPI【财务凭证】核算维度赋值【分享】
WebAPI【财务凭证】核算维度赋值【分享】
WebAPI查询表单数据接口示例
金蝶社区
WebAPI批量保存接口示例
金蝶社区
小技巧 - 如何逐步构建采购订单Web API保存接口参数
小技巧 - 如何逐步构建采购订单Web API保存接口参数
K3Cloud系统集成实现下推单据转换调用【分享】
K3Cloud系统集成实现下推单据转换调用【分享】
K/3Cloud WebAPI 调用任意操作实现方案【分享】
K/3Cloud WebAPI 调用任意操作实现方案【分享】
注意:WebAPI方式调用是不需要发布站点的,需要发布站点的就不是WebAPI方式
——————置顶完毕 分割线————————
发布SI站点:
开单贴,K/3Cloud系统集成配置及示例
开单贴,K/3Cloud系统集成配置及示例
发布SI站点出错解决:
【已解决】5.0 集成站点发布失败!!!
【已解决】5.0 集成站点发布失败!!!
SI的Web Service方式:
Web Service方式 【销售普通发票】保存【分享】
Web Service方式 【销售普通发票】保存【分享】
Web Service 不引用SDK方式 新增【用户】 【分享】
Web Service 不引用SDK方式 新增【用户】 【分享】
SI的Json格式:
K3Cloud系统集成Json方式调用【分享】
K3Cloud系统集成Json方式调用【分享】
采用Json方式集成调用批量查询数据【分享】
采用Json方式集成调用批量查询数据【分享】
系统集成构造Json格式包含子单据体示例【分享】
系统集成构造Json格式包含子单据体示例【分享】
Web Service 上传附件Json格式【分享】
Web Service 上传附件Json格式【分享】
Web API方式:
K/3 Cloud WebAPI接口说明文档
欢迎访问金蝶云社区
WebApi之新接口推广
WebApi之新接口推广
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
K/3 Cloud Web API集成开发客户端不引用组件示例【分享】
WebAPI【财务凭证】核算维度赋值【分享】
WebAPI【财务凭证】核算维度赋值【分享】
PHP方式调用:
Cloud系统集成 PHP完整调用示例【分享】
Cloud系统集成 PHP完整调用示例【分享】
K/3 Cloud Web API销售出库单PHP完整示例【分享】
K/3 Cloud Web API销售出库单PHP完整示例【分享】
Java方式调用:
Cloud系统集成 Java完整调用示例【分享】
Cloud系统集成 Java完整调用示例【分享】
K/3 Cloud Web API集成开发Java完整示例【分享】
K/3 Cloud Web API集成开发Java完整示例【分享】
另:
基于Cloud代理组件方式集成:
基于.net Framework4.0 第三方通过Cloud代理组件集成开发【分享】
基于.net Framework4.0 第三方通过Cloud代理组件集成开发【分享】
硬件集成:
【分享】客制化控件插件实现客户端设备集成
【分享】客制化控件插件实现客户端设备集成
【分享】客制化控件插件实现客户端设备集成