SOP 1.1.0發布,此次更新內容如下:
SOP Admin新增用戶登錄 新增基礎SDK(Java,C#) doc下個版本將會發布:
文檔整合 springmvc項目接入demo 限流管理本次更新的重點是基礎SDK,Java版SDK使用方式如下:
String url = "http://localhost:8081/api"; // zuulString appId = "2019032617262200001";String privateKey = "你的私鑰";// 聲明一個就行OpenClient client = new OpenClient(url, appId, privateKey);// 標準用法@Testpublic void testGet() { // 創建請求對象 GetStoryRequest request = new GetStoryRequest(); // 請求參數 GetStoryModel model = new GetStoryModel(); model.setName("白雪公主"); request.setBizModel(model); // 發送請求 GetStoryResponse response = client.execute(request); if (response.isSuccess()) { // 返回結果 System.out.println(String.format("成功!response:%s\n響應原始內容:%s", JSON.toJSONString(response), response.getBody())); } else { System.out.println("錯誤,subCode:" + response.getSubCode() + ", subMsg:" + response.getSubMsg()); }}
C#版本SDK使用方式如下:
static string url = "http://localhost:8081/api"; static string appId = "201904035630907729292csharp"; // 私鑰, PKCS1 2048 static string privateKey = "你的私鑰"; // 從文件中加載 //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(); } // 標準用法 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); } }
關於SOP
SOP(Simple Open Platform)一個開放平臺解決方案項目,基於Spring Cloud實現,目標是能夠讓用戶快速得搭建起自己的開放平臺。
SOP提供了兩種接口調用方式,分別是:支付寶開放平臺的調用方式和淘寶開放平臺的調用方式。 通過簡單的配置後,你的項目就具備了和支付寶開放平臺的一樣的接口提供能力。
SOP封裝了開放平臺大部分功能包括:籤名驗證、統一異常處理、統一返回內容 、業務參數驗證(JSR-303)、秘鑰管理等,未來還會實現更多功能。
項目特點 接入方式簡單,與老項目不衝突,老項目註冊到註冊中心,然後在方法上加上註解即可。 架構鬆耦合,業務代碼實現在各自微服務上,SOP不參與業務實現,這也是Spring Cloud微服務體系帶來的好處。 擴展簡單,開放平臺對應的功能各自獨立,可以自定義實現自己的需求,如:更改參數,更改籤名規則等。誰可以使用這個項目 有現成的項目,想改造成開放平臺供他人調用 有現成的項目,想暴露其中幾個接口並通過開放平臺供他人調用 想搭一個開放平臺新項目,並結合微服務的方式去維護 對開放平臺感興趣的朋友以上情況都可以考慮使用SOP
架構圖