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 客戶代碼、名字,點啟動,自動生成客戶

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM