YiKdWebClient 1.0.0.5
See the version list below for details.
dotnet add package YiKdWebClient --version 1.0.0.5
NuGet\Install-Package YiKdWebClient -Version 1.0.0.5
<PackageReference Include="YiKdWebClient" Version="1.0.0.5" />
paket add YiKdWebClient --version 1.0.0.5
#r "nuget: YiKdWebClient, 1.0.0.5"
// Install YiKdWebClient as a Cake Addin #addin nuget:?package=YiKdWebClient&version=1.0.0.5 // Install YiKdWebClient as a Cake Tool #tool nuget:?package=YiKdWebClient&version=1.0.0.5
YiKdWebClient代码示例及介绍
实现金蝶云星空第三方授权登录 使用纯HTTP协议实现 移除了对官方SDK的依赖 移除了对Newtonsoft.Json的依赖
调用方式简单 如下示例:
1.第三方授权认证
///1.第三方授权认证
string Formid = "SEC_User";
string Json =@"{""IsUserModelInit"":""true"",""Number"":""Administrator"",""IsSortBySeq"":""false""}";
YiK3CloudClient yiK3CloudClient = new YiKdWebClient.YiK3CloudClient();
var resultJson = yiK3CloudClient.View(Formid, Json);
可以获取到请求的真实地址,和真实请求的body 如下图
可以利用此信息,使用postman 等接口调试工具进行调试,更方便快捷。 也可以使用其它开发语言进行请求,原理一致
2.旧版用户名密码认证
///2.旧版用户名密码认证
string Formid = "SEC_User";
string Json =@"{""IsUserModelInit"":""true"",""Number"":""Administrator"",""IsSortBySeq"":""false""}";
YiK3CloudClient yiK3CloudClient = new YiKdWebClient.YiK3CloudClient();
yiK3CloudClient.LoginType= LoginType.ValidateLogin;
yiK3CloudClient.validateLoginSettingsModel=new ValidateLoginSettingsModel() { Url = @"http://127.0.0.1/K3Cloud/", DbId= "629bd5285d655d", UserName="demo",Password="123456",lcid=2052};
var resultJson = yiK3CloudClient.View(Formid, Json);
3.集成密钥文件认证
string Formid = "SEC_User";
string Json = @"{""IsUserModelInit"":""true"",""Number"":""Administrator"",""IsSortBySeq"":""false""}";
YiK3CloudClient yiK3CloudClient = new YiKdWebClient.YiK3CloudClient();
yiK3CloudClient.LoginType = LoginType.LoginBySimplePassport;
string cnfFilePath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "YiKdWebCfg", "API测试.cnf");
yiK3CloudClient.LoginBySimplePassportModel = new LoginBySimplePassportModel() { Url = @"http://127.0.0.1/K3Cloud/", CnfFilePath = cnfFilePath };
var resultJson = yiK3CloudClient.View(Formid, Json);
4.API签名认证
string Formid = "SEC_User";
string Json = @"{""IsUserModelInit"":""true"",""Number"":""Administrator"",""IsSortBySeq"":""false""}";
YiK3CloudClient yiK3CloudClient = new YiKdWebClient.YiK3CloudClient();
yiK3CloudClient.LoginType=LoginType.LoginByApiSignHeaders;
var resultJson = yiK3CloudClient.View(Formid, Json);
Console.WriteLine(resultJson);
使用postman,Apipost 工具调试
如下为使用postman,Apipost 工具的方法
//签名请求头的字符串,可以直接导入postman,Apipost
string RequestHeadersString = yiK3CloudClient.RequestHeadersString;
Console.WriteLine("签名请求头的字符串,可以直接导入postman,Apipost:");
Console.WriteLine(RequestHeadersString);
//真实的请求地址
string RequestUrl = yiK3CloudClient.ReturnOperationWebModel.RequestUrl;
Console.WriteLine("真实的请求地址: ");
Console.WriteLine(RequestUrl);
//真实的请求报文
string RealRequestBody = yiK3CloudClient.ReturnOperationWebModel.RealRequestBody;
Console.WriteLine("真实的请求报文: ");
Console.WriteLine(RealRequestBody);
Console.WriteLine("请求结果: ");
Console.WriteLine(resultJson);
运行结果如下:
JSON 格式
传入方法的JSON格式,与金蝶官方文档要求的格式完全一致. 注:(官方文档的JSON格式,并不是最终http请求的格式)
当前已经支持编译的版本
netstandard 2.0; netstandard 2.1; netframework 4.8 ; netframework 4.8.1 ; netcore 6.0; netcore 8.0;
项目的依赖项
System.Net.Http; System.Text.Json; System.Security.Cryptography.Cng;
nuget地址:
https://www.nuget.org/packages/YiKdWebClient
nuget包的使用方法
配置文件路径
配置路如下 YiKdWebCfg/appsettings.xml
配置文件内容
注意:(最新公有云可能强制要求走网关(https://api.kingdee.com/galaxyapi/) 走网关的方式需要使用API签名认证的模式。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="X-KDApi-AcctID" value="629bd5285d655d"/>
<add key="X-KDApi-UserName" value="Administrator"/>
<add key="X-KDApi-AppID" value="2********************P"/>
<add key="X-KDApi-AppSec" value="a***********************7"/>
<add key="X-KDApi-LCID" value="2052"/>
<add key="X-KDApi-ServerUrl" value="http://127.0.0.1/k3cloud/"/>
</appSettings>
</configuration>
功能列表(功能名称与官方功能名方式相同,以此类推)
接口名称 | 接口含义 |
---|---|
Save | 保存 |
BatchSave | 批量保存 |
Audit | 审核 |
Delete | 删除 |
UnAudit | 反审核 |
Submit | 提交 |
View | 查看 |
ExecuteBillQuery | 单据查询 |
Draft | 暂存 |
Allocate | 分配 |
ExecuteOperation | 操作接口 |
FlexSave | 弹性域保存 |
SendMsg | 发送消息 |
Push | 下推 |
GroupSave | 分组保存 |
Disassembly | 拆单 |
QueryBusinessInfo | 查询单据信息 |
QueryGroupInfo | 查询分组信息 |
WorkflowAudit | 工作流审批 |
GroupDelete | 分组删除 |
CancelAllocate | 取消分配 |
SwitchOrg | 切换组织接口 |
CancelAssign | 撤销服务接口 |
GetSysReportData | 获取报表数据 |
AttachmentUpload | 上传附件 |
AttachmentDownLoad | 下载附件 |
项目地址
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 is compatible. net471 is compatible. net472 is compatible. net48 is compatible. net481 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETFramework 4.7
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETFramework 4.7.1
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETFramework 4.7.2
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETFramework 4.8
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETFramework 4.8.1
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETStandard 2.0
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
.NETStandard 2.1
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
net6.0
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
-
net8.0
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Cng (>= 5.0.0)
- System.Text.Json (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.