WebApi,不引用WebApi.Client.dll调用WebApi接口
1、打开VS,新建项目控制台应用程序

2、添加引用和使用
Newtonsoft.Json.dll
using Newtonsoft.Json.Linq;

3、修改组织机构代码 和 客户代码、名字

4、添加类 InvokeHelper
5、添加使用
using Newtonsoft.Json;
6、添加 public
public class InvokeHelper
{
}
7、星空地址
//星空 业务站点地址 private static string CloudUrl = "http://127.0.1/K3Cloud/";
8、登录
//登录
public static string Login()
{
HttpClient httpClient = new HttpClient();
httpClient.Url = string.Concat(CloudUrl,
"Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc");
List<object> Parameters = new List<object>();
Parameters.Add("5e5b91e99193fb");//账套
Parameters.Add("administrator");//用户名
Parameters.Add("888888");//密码
Parameters.Add(2502);//2052代表中文
httpClient.Content = JsonConvert.SerializeObject(Parameters);
return httpClient.SysncRequest();
}

9、保存
//保存
public static string Save(string formId, string content)
{
HttpClient httpClient = new HttpClient();
httpClient.Url = string.Concat(CloudUrl,
"Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc");
List<object> Parameters = new List<object>();
Parameters.Add(formId);//业务对象Id
Parameters.Add(content);//Json字串
httpClient.Content = JsonConvert.SerializeObject(Parameters);
return httpClient.SysncRequest();
}

10、添加类 HttpClient

11、修改Json 客户代码、名字,点启动,自动生成客户




浙公网安备 33010602011771号