diff --git a/sop-sdk/sdk-csharp/SDKCSharp.sln b/sop-sdk/sdk-csharp/SDKCSharp.sln index 96c65537..924542cb 100644 --- a/sop-sdk/sdk-csharp/SDKCSharp.sln +++ b/sop-sdk/sdk-csharp/SDKCSharp.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDKCSharp", "SDKCSharp\SDKCSharp.csproj", "{5461AAE5-F701-4A39-9D81-22BC6A80CFF9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDKTest", "SDKTest\SDKTest.csproj", "{34D6DDAB-895D-4B31-A18F-157BBF6393A1}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,9 +13,5 @@ Global {5461AAE5-F701-4A39-9D81-22BC6A80CFF9}.Debug|Any CPU.Build.0 = Debug|Any CPU {5461AAE5-F701-4A39-9D81-22BC6A80CFF9}.Release|Any CPU.ActiveCfg = Release|Any CPU {5461AAE5-F701-4A39-9D81-22BC6A80CFF9}.Release|Any CPU.Build.0 = Release|Any CPU - {34D6DDAB-895D-4B31-A18F-157BBF6393A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34D6DDAB-895D-4B31-A18F-157BBF6393A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34D6DDAB-895D-4B31-A18F-157BBF6393A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34D6DDAB-895D-4B31-A18F-157BBF6393A1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/sop-sdk/sdk-csharp/SDKCSharp/Program.cs b/sop-sdk/sdk-csharp/SDKCSharp/Program.cs index 00fb0ff0..6919014e 100644 --- a/sop-sdk/sdk-csharp/SDKCSharp/Program.cs +++ b/sop-sdk/sdk-csharp/SDKCSharp/Program.cs @@ -1,10 +1,92 @@ -namespace SDKTest +using System; +using System.Collections; +using System.Collections.Generic; +using SDKCSharp.Client; +using SDKCSharp.Model; +using SDKCSharp.Request; +using SDKCSharp.Response; +using SDKCSharp.Utility; + +namespace SDKTest { class MainClass { + static string url = "http://localhost:8081/api"; // zuul + static string appId = "201904035630907729292csharp"; + // 私钥, PKCS1 1024 + static string privateKey = "MIIEowIBAAKCAQEA5+OvJxeSzf44NxQ/cl7Ii+BzPg2k6sRcvH4ffOtU5Dzq1/oEvg02nxIhmwOHBZmjbmuUu0aLsfglUTAwqfXftfAKZidshsgj9NNh0/kxk0avRZ1UoljWGz/FxVZA0ogbxxhohPZ9jWcD+eBQcIwF2DtHfAJqWWZrYFnCMeHD8mPzxo2kwXSvDzi0vf9I2tKiYvNG26a9FqeYtPOoi81sdS3+70HOMdxP8ejXtyfnKpKz7Dx506LCIRS5moWS3Q5eTLV3NGX/1CSJ8wpQA2DAQTjVhX5eVu7Yqz12t8W+sjWM/tHUR6cgwYYR10p7tSCeCPzkigjGxKm4cYXWtATQJQIDAQABAoIBAHFDsgrrJca+NKEan77ycwx3jnKx4WrWjOF4zVKL9AQjiSYDNgvKknJyPb3kpC/lEoHdxGERHSzJoxib7DkoIqRQYhPxj73pxj5QfYk3P7LLJNNg/LTrpXDb3nL8JV9wIflGf87qQvstZTDJEyFWE4jBs7Hr0BxovWvri8InnzkmERJ1cbGJgNHe1Y3Zo2tw0yaHxQCxLuajP+notRZhD9bEp7uKeI0w9AvlW6k8m/7y10F0BK/TlyW8rQiEC391yOiRYoMcUh4hd2Q9bMx3jngZgX8PXIvZZcup4/pvWlv1alwhB2tsnLdazP62r1MO80vLyLunzGO+7WwCjEYlVaECgYEA+lQRFmbhKaPuAuXMtY31Fbga8nedka5TjnEV7+/kX+yowE2OlNujF+ZG8UTddTxAGv56yVNi/mjRlgD74j8z0eOsgvOq9mwbCrgLhLo51H9O/wAxtb+hBKtC5l50pBr4gER6d8W6EQNTSGojnMIaLXTkAZ5Qf6Z8e2HFVdOn0X0CgYEA7SSrTokwzukt5KldNu5ukyyd+C3D1i6orbg6qD73EP9CfNMfGSBn7dDv9wMSJH01+Ty+RgTROgtjGRDbMJWnfbdt/61NePr9ar5sb6Nbsf7/I0w7cZF5dsaFYgzaOfQYquzXPbLQHkpMT64bqpv/Mwy4F2lFvaYWY5fA4pC2uckCgYEAg75Ym9ybJaoTqky8ttQ2Jy8UZ4VSVQhVC0My02sCWwWXLlXi8y7An+Rec73Ve0yxREOn5WrQT6pkmzh7V/ABWrYi5WxODpCIjtSbo0fLBa3Wqle00b0/hdCITetqIa/cFs1zUrOqICgK3bKWeXqiAkhhcwSZwwSgwOKM04Wn7ZUCgYBvhHX2mbdVJfyJ8kc+hMOE/E9RHRxiBVEXWHJlGi8PVCqNDq8qHr4g7Mdbzprig+s0yKblwHAvrpkseWvKHiZEjVTyDipHgShY4TGXEigVvUd37uppTrLi8xpYcJjS9gH/px7VCdiq1d+q/MJP6coJ1KphgATm2UrgDMYNBWaYWQKBgEHRxrmER7btUF60/YgcqPHFc8RpYQB2ZZE0kyKGDqk2Data1XYUY6vsPAU28yRLAaWr/D2H17iyLkxP80VLm6QhifxCadv90Q/Wl1DFfOJQMW6avyQ0so6G0wFq/LJxaFK4iLXQn1RJnmTp6BYiJMmK2BhFbRzw8ssMoF6ad2rr"; + + //static string filePath = "/Users/thc/logs/priKey.txt"; + //static OpenClient client = new OpenClient(url, appId, filePath, true); + + // 声明一个就行 + static OpenClient client = new OpenClient(url, appId, privateKey); + + public static void Main(string[] args) { - + TestGet(); + TestCommon(); + } + + // 标准用法 + private static void TestGet() + { + // 创建请求对象 + GetStoryRequest request = new GetStoryRequest(); + // 请求参数 + GetStoryModel model = new GetStoryModel(); + model.Name = "白雪公主"; + request.BizModel = model; + + // 发送请求 + GetStoryResponse response = client.Execute(request); + + if (response.IsSuccess()) + { + // 返回结果 + Console.WriteLine("成功!response:{0}\n响应原始内容:{1}", JsonUtil.ToJSONString(response), response.Body); + } + else + { + Console.WriteLine("错误, code:{0}, msg:{1}, subCode:{2}, subMsg:{3}", + response.Code, response.Msg, response.SubCode, response.SubMsg); + } + } + + // 懒人版,如果不想添加Request,Response,Model。可以用这种方式,返回全部是String,后续自己处理json + private static void TestCommon() + { + // 创建请求对象 + CommonRequest request = new CommonRequest("alipay.story.find"); + // 请求参数 + Dictionary bizModel = new Dictionary + { + ["name"] = "白雪公主" + }; + + request.BizModel = bizModel; + + // 发送请求 + CommonResponse response = client.Execute(request); + + if (response.IsSuccess()) + { + // 返回结果 + string body = response.Body; + Dictionary dict = JsonUtil.ParseToDictionary(body); + + Console.WriteLine("Dictionary内容:"); + foreach (var item in dict) + { + Console.WriteLine("{0}:{1}", item.Key, item.Value); + } + } + else + { + Console.WriteLine("错误, code:{0}, msg:{1}, subCode:{2}, subMsg:{3}", + response.Code, response.Msg, response.SubCode, response.SubMsg); + } } } } diff --git a/sop-sdk/sdk-csharp/SDKCSharp/Response/BaseResponse.cs b/sop-sdk/sdk-csharp/SDKCSharp/Response/BaseResponse.cs index 7d5f7f76..cf9fa8d6 100644 --- a/sop-sdk/sdk-csharp/SDKCSharp/Response/BaseResponse.cs +++ b/sop-sdk/sdk-csharp/SDKCSharp/Response/BaseResponse.cs @@ -36,9 +36,9 @@ namespace SDKCSharp.Response public string SubMsg { get; set; } /// - /// 数据 + /// 响应原始内容 /// - [JsonProperty("body")] + [JsonIgnore] public string Body { get; set; } /// diff --git a/sop-sdk/sdk-csharp/SDKTest/Program.cs b/sop-sdk/sdk-csharp/SDKTest/Program.cs deleted file mode 100644 index 8ca9fd37..00000000 --- a/sop-sdk/sdk-csharp/SDKTest/Program.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using SDKCSharp.Client; -using SDKCSharp.Model; -using SDKCSharp.Request; -using SDKCSharp.Response; -using SDKCSharp.Utility; - -namespace SDKTest -{ - class MainClass - { - static string url = "http://localhost:8081/api"; // zuul - static string appId = "201904035630907729292csharp"; - // 私钥, PKCS1 1024 - static string privateKey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ybJaoTqky8ttQ2Jy8UZ4VSVQhVC0My02sCWwWXLlXi8y7An+Rec73Ve0yxREOn5WrQT6pkmzh7V/ABWrYi5WxODpCIjtSbo0fLBa3Wqle00b0/hdCITetqIa/cFs1zUrOqICgK3bKWeXqiAkhhcwSZwwSgwOKM04Wn7ZUCgYBvhHX2mbdVJfyJ8kc+hMOE/E9RHRxiBVEXWHJlGi8PVCqNDq8qHr4g7Mdbzprig+s0yKblwHAvrpkseWvKHiZEjVTyDipHgShY4TGXEigVvUd37uppTrLi8xpYcJjS9gH/px7VCdiq1d+q/MJP6coJ1KphgATm2UrgDMYNBWaYWQKBgEHRxrmER7btUF60/YgcqPHFc8RpYQB2ZZE0kyKGDqk2Data1XYUY6vsPAU28yRLAaWr/D2H17iyLkxP80VLm6QhifxCadv90Q/Wl1DFfOJQMW6avyQ0so6G0wFq/LJxaFK4iLXQn1RJnmTp6BYiJMmK2BhFbRzw8ssMoF6ad2rr"; - - static string filePath = "/Users/thc/logs/priKey.txt"; - - // 声明一个就行 - //static OpenClient client = new OpenClient(url, appId, privateKey); - static OpenClient client = new OpenClient(url, appId, filePath, true); - - public static void Main(string[] args) - { - TestGet(); - } - - // 标准用法 - private static void TestGet() - { - // 创建请求对象 - GetStoryRequest request = new GetStoryRequest(); - // 请求参数 - GetStoryModel model = new GetStoryModel(); - model.Name = "白雪公主"; - request.BizModel = model; - - // 发送请求 - GetStoryResponse response = client.Execute(request); - - if (response.IsSuccess()) - { - // 返回结果 - Console.WriteLine("成功!故事名称:{0}", response.Name); - } - else - { - Console.WriteLine("错误, code:{0}, msg:{1}, subCode:{2}, subMsg:{3}", - response.Code, response.Msg, response.SubCode, response.SubMsg); - } - } - - // 懒人版,如果不想添加Request,Response,Model。可以用这种方式,返回全部是String,后续自己处理json - private static void TestCommon() - { - // 创建请求对象 - CommonRequest request = new CommonRequest("alipay.story.find"); - // 请求参数 - Dictionary bizModel = new Dictionary - { - ["name"] = "白雪公主" - }; - - request.BizModel = bizModel; - - // 发送请求 - CommonResponse response = client.Execute(request); - - if (response.IsSuccess()) - { - // 返回结果 - string body = response.Body; - Dictionary dict = JsonUtil.ParseToDictionary(body); - Console.WriteLine(dict.ToString()); - } - else - { - Console.WriteLine("错误, code:{0}, msg:{1}, subCode:{2}, subMsg:{3}", - response.Code, response.Msg, response.SubCode, response.SubMsg); - } - } - } -} diff --git a/sop-sdk/sdk-csharp/SDKTest/SDKTest.csproj b/sop-sdk/sdk-csharp/SDKTest/SDKTest.csproj deleted file mode 100644 index 3a2dc466..00000000 --- a/sop-sdk/sdk-csharp/SDKTest/SDKTest.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - netcoreapp2.0 - - - - - -