• 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 客户代码、名字,点启动,自动生成客户

     

     

  • 相关阅读:
    robotframework-ride1.7.3.1更新安装
    批量删除新浪微博
    Redis
    GET和POST两种基本请求方法的区别
    selenium2自动化测试实战--基于Python语言
    同步/异步/阻塞/非阻塞/BIO/NIO/AIO
    HTTP抓包实战
    LCT模板(BZOJ2631)
    树链剖分模板(BZOJ3083)
    凸包(BZOJ1069)
  • 原文地址:https://www.cnblogs.com/zfangfang/p/13952106.html
Copyright © 2020-2023  润新知