{"id":102658,"date":"2026-09-09T10:41:16","date_gmt":"2026-09-09T02:41:16","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/102658.html"},"modified":"2026-09-09T10:41:16","modified_gmt":"2026-09-09T02:41:16","slug":"%e7%ac%ac59%e7%af%87%ef%bd%9cgrpc-%e5%ae%a2%e6%88%b7%e7%ab%af%e5%ba%93%e9%80%82%e9%85%8d-harmonyos","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/102658.html","title":{"rendered":"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS"},"content":{"rendered":"<h2>\u7b2c59\u7bc7&#xff5c;gRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260909024113-6aa0c749979a6.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe 1&#xff1a;gRPC\u5ba2\u6237\u7aef\u9002\u914d\u5c01\u9762\u56fe&#xff0c;\u7528\u6765\u6982\u62ec\u672c\u6587\u4e3b\u9898\u3001\u9002\u914d\u5bf9\u8c61\u548c\u5de5\u7a0b\u8fb9\u754c\u3002<\/p>\n<p>gRPC \u7c7b\u5e93\u9002\u914d\u8981\u540c\u65f6\u770b HTTP2\u3001\u8bc1\u4e66\u3001\u8d85\u65f6\u548c\u6d41\u5f0f\u56de\u8c03&#xff0c;\u4e0d\u9002\u5408\u53ea\u5199\u4e00\u4e2a\u8bf7\u6c42\u793a\u4f8b\u3002<\/p>\n<p>\u672c\u6587\u56f4\u7ed5 RPC \u8bf7\u6c42 \u548c \u6d41\u5f0f\u56de\u8c03 \u5c55\u5f00&#xff0c;\u76ee\u6807\u4e0d\u662f\u628a\u5e93\u63a5\u8fdb\u5de5\u7a0b\u540e\u622a\u56fe\u7ed3\u675f&#xff0c;\u800c\u662f\u628a\u6765\u6e90\u3001\u7248\u672c\u3001\u914d\u7f6e\u3001\u5c01\u88c5\u3001\u8fd0\u884c\u548c\u9a8c\u6536\u5199\u6210\u4e00\u6761\u8bfb\u8005\u53ef\u4ee5\u590d\u73b0\u7684\u94fe\u8def\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260909024114-6aa0c74a4ec24.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe 2&#xff1a;gRPC\u5ba2\u6237\u7aef\u9002\u914d\u6d41\u7a0b\u56fe&#xff0c;\u7528\u6765\u8bf4\u660e\u4ece\u9700\u6c42\u62c6\u89e3\u3001\u4f9d\u8d56\u63a5\u5165\u3001\u5c01\u88c5\u5b9e\u73b0\u5230\u56de\u5f52\u9a8c\u6536\u7684\u4e3b\u8981\u6b65\u9aa4\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260909024115-6aa0c74b1a237.png\" alt=\"\u8bf7\u6dfb\u52a0\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe 3&#xff1a;gRPC\u5ba2\u6237\u7aef\u9002\u914d\u7ed3\u6784\u56fe&#xff0c;\u7528\u6765\u8bf4\u660e\u914d\u7f6e\u5c42\u3001\u9002\u914d\u5c42\u3001\u670d\u52a1\u5c42\u3001\u9875\u9762\u5c42\u548c\u6392\u9519\u8bb0\u5f55\u4e4b\u95f4\u7684\u804c\u8d23\u3002<\/p>\n<h3>1. \u8fd9\u7c7b\u5e93\u5148\u89e3\u51b3\u54ea\u4e2a\u5de5\u7a0b\u95ee\u9898<\/h3>\n<p>gRPC\u5ba2\u6237\u7aef\u9002\u914d\u4e0d\u80fd\u4ece API \u540d\u79f0\u5f00\u59cb\u8bb2&#xff0c;\u8981\u5148\u8bf4\u6e05\u695a\u5b83\u89e3\u51b3\u4ec0\u4e48\u5de5\u7a0b\u95ee\u9898\u3002\u5b9e\u9645\u63a5\u5165\u65f6&#xff0c;\u8bfb\u8005\u6700\u5173\u5fc3\u7684\u662f\u5e93\u8fdb\u5165\u9879\u76ee\u540e\u7531\u54ea\u4e00\u5c42\u8c03\u7528\u3001\u5931\u8d25\u4ee5\u540e\u770b\u54ea\u91cc\u3001\u7248\u672c\u5347\u7ea7\u65f6\u54ea\u4e9b\u5730\u65b9\u9700\u8981\u56de\u5f52\u3002<\/p>\n<p>\u672c\u6587\u628a\u95ee\u9898\u6536\u655b\u5230 RPC \u8bf7\u6c42 \u7684\u8f93\u5165\u3001\u6d41\u5f0f\u56de\u8c03 \u7684\u6267\u884c\u548c latencyMs \u7684\u9a8c\u6536\u6307\u6807\u3002\u8fd9\u6837\u5199\u7684\u597d\u5904\u662f\u8303\u56f4\u660e\u786e&#xff0c;\u8bfb\u8005\u4e0d\u4f1a\u628a\u9009\u578b\u3001\u5c01\u88c5\u3001\u9875\u9762\u548c\u53d1\u5e03\u8bf4\u660e\u6df7\u6210\u4e00\u56e2\u3002<\/p>\n<table>\n<tr>\u5224\u65ad\u70b9\u672c\u6587\u5904\u7406\u65b9\u5f0f\u8bfb\u8005\u843d\u5730\u65f6\u8981\u66ff\u6362\u7684\u5185\u5bb9<\/tr>\n<tbody>\n<tr>\n<td>\u8f93\u5165\u6765\u6e90<\/td>\n<td>\u7edf\u4e00\u4e3a RPC \u8bf7\u6c42<\/td>\n<td>\u66ff\u6362\u6210\u771f\u5b9e\u9875\u9762\u3001\u6587\u4ef6\u6216\u8bbe\u5907\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u6838\u5fc3\u52a8\u4f5c<\/td>\n<td>\u6536\u655b\u5230 \u6d41\u5f0f\u56de\u8c03<\/td>\n<td>\u66ff\u6362\u6210\u4e09\u65b9\u5e93\u771f\u5b9e API<\/td>\n<\/tr>\n<tr>\n<td>\u9a8c\u6536\u6307\u6807<\/td>\n<td>\u4f7f\u7528 latencyMs \u505a\u6700\u5c0f\u5224\u65ad<\/td>\n<td>\u66ff\u6362\u6210\u4e1a\u52a1\u8ba4\u53ef\u7684\u7ed3\u679c\u5b57\u6bb5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2. \u6e90\u7801\u548c\u8d44\u6599\u5b9a\u4f4d<\/h3>\n<p>\u9002\u914d\u524d\u5148\u5efa\u7acb\u6e90\u7801\u5730\u56fe\u3002\u5373\u4f7f\u6ca1\u6709\u771f\u5b9e\u9879\u76ee\u76ee\u5f55&#xff0c;\u4e5f\u8981\u628a\u5efa\u8bae\u4f4d\u7f6e\u5199\u6e05\u695a&#xff0c;\u8ba9\u8bfb\u8005\u77e5\u9053\u6bcf\u6bb5\u4ee3\u7801\u5e94\u8be5\u653e\u5728\u54ea\u4e00\u5c42\u3002<\/p>\n<table>\n<tr>\u5c42\u7ea7\u5efa\u8bae\u6587\u4ef6\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u4f9d\u8d56\u5165\u53e3<\/td>\n<td>oh-package.json5 \u6216 entry\/src\/main\/cpp\/CMakeLists.txt<\/td>\n<td>\u56fa\u5b9a\u7248\u672c\u3001\u6e90\u7801\u6216 Native \u4ea7\u7269<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u914d\u5c42<\/td>\n<td>entry\/src\/main\/ets\/adapter\/GrpcClientAdapter.ets<\/td>\n<td>\u5904\u7406\u8f93\u5165\u3001\u9519\u8bef\u548c\u4e09\u65b9 API \u5dee\u5f02<\/td>\n<\/tr>\n<tr>\n<td>\u670d\u52a1\u5c42<\/td>\n<td>entry\/src\/main\/ets\/service\/GrpcClientService.ets<\/td>\n<td>\u66b4\u9732\u4e1a\u52a1\u53ef\u8bfb\u65b9\u6cd5<\/td>\n<\/tr>\n<tr>\n<td>\u793a\u4f8b\u9875\u9762<\/td>\n<td>entry\/src\/main\/ets\/pages\/GrpcClientServicePage.ets<\/td>\n<td>\u63d0\u4f9b\u53ef\u590d\u73b0\u9a8c\u6536\u5165\u53e3<\/td>\n<\/tr>\n<tr>\n<td>\u9a8c\u6536\u8bb0\u5f55<\/td>\n<td>docs\/grpc-client-acceptance.md<\/td>\n<td>\u4fdd\u5b58\u7248\u672c\u3001\u547d\u4ee4\u548c\u9650\u5236<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3. \u73af\u5883\u548c\u7248\u672c\u8fb9\u754c<\/h3>\n<p>\u7248\u672c\u8fb9\u754c\u9700\u8981\u5199\u5728\u6b63\u6587\u524d\u534a\u90e8\u5206\u3002HarmonyOS API\u3001DevEco Studio\u3001ohpm \u5305\u7248\u672c\u3001Native ABI\u3001\u8bbe\u5907\u80fd\u529b\u90fd\u4f1a\u5f71\u54cd\u7ed3\u679c&#xff0c;\u4e0d\u80fd\u9ed8\u8ba4\u8bfb\u8005\u7684\u73af\u5883\u548c\u4f5c\u8005\u4e00\u81f4\u3002<\/p>\n<table>\n<tr>\u73af\u5883\u9879\u793a\u4f8b\u503c\u68c0\u67e5\u91cd\u70b9<\/tr>\n<tbody>\n<tr>\n<td>HarmonyOS API<\/td>\n<td>API 12&#043; \u6216\u9879\u76ee\u5b9e\u9645\u7248\u672c<\/td>\n<td>\u7cfb\u7edf\u80fd\u529b\u3001\u6743\u9650\u548c\u7ec4\u4ef6\u884c\u4e3a<\/td>\n<\/tr>\n<tr>\n<td>\u5f00\u53d1\u5de5\u5177<\/td>\n<td>DevEco Studio 5.x<\/td>\n<td>\u6784\u5efa\u3001\u9884\u89c8\u548c\u7b7e\u540d\u6d41\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u4f9d\u8d56\u5f62\u5f0f<\/td>\n<td>ArkTS \u5305 \/ Native so \/ \u6e90\u7801\u6a21\u5757<\/td>\n<td>\u51b3\u5b9a\u6392\u67e5\u5165\u53e3<\/td>\n<\/tr>\n<tr>\n<td>\u76ee\u6807\u8bbe\u5907<\/td>\n<td>\u6a21\u62df\u5668\u6216\u771f\u673a<\/td>\n<td>\u591a\u5a92\u4f53\u3001\u84dd\u7259\u3001\u76f8\u673a\u7b49\u80fd\u529b\u8981\u771f\u673a\u786e\u8ba4<\/td>\n<\/tr>\n<tr>\n<td>\u56de\u5f52\u5165\u53e3<\/td>\n<td>\u793a\u4f8b\u9875 &#043; \u547d\u4ee4\u884c<\/td>\n<td>\u80fd\u91cd\u590d\u89e6\u53d1\u6838\u5fc3\u80fd\u529b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>4. \u914d\u7f6e\u5165\u53e3\u5148\u6536\u53e3<\/h3>\n<p>\u914d\u7f6e\u5c42\u53ea\u8d1f\u8d23\u8ba9\u4f9d\u8d56\u8fdb\u5165\u5de5\u7a0b&#xff0c;\u4e0d\u8981\u6df7\u5165\u4e1a\u52a1\u5224\u65ad\u3002\u5305\u7ba1\u7406\u7c7b\u5e93\u56fa\u5b9a\u7248\u672c&#xff0c;Native \u7c7b\u5e93\u56fa\u5b9a include\u3001lib \u548c ABI&#xff0c;\u6d89\u53ca\u6743\u9650\u7684\u5e93\u8fd8\u8981\u8865\u6a21\u5757\u58f0\u660e\u3002<\/p>\n<p>{<br \/>\n  &#034;name&#034;: &#034;grpc-client-sample&#034;,<br \/>\n  &#034;version&#034;: &#034;1.0.0&#034;,<br \/>\n  &#034;dependencies&#034;: {<br \/>\n    &#034;&#064;demo\/grpc-client&#034;: &#034;1.0.0&#034;<br \/>\n  },<br \/>\n  &#034;metadata&#034;: {<br \/>\n    &#034;verifiedApi&#034;: &#034;API 12&#043;&#034;,<br \/>\n    &#034;entry&#034;: &#034;GrpcClientService&#034;<br \/>\n  }<br \/>\n}<\/p>\n<p>\u8fd9\u6bb5\u914d\u7f6e\u7684\u8fb9\u754c\u662f\u201c\u53ef\u8ffd\u8e2a\u201d\u3002\u5b83\u8ba9\u8bfb\u8005\u77e5\u9053\u4f9d\u8d56\u4ece\u54ea\u91cc\u6765\u3001\u7248\u672c\u662f\u4ec0\u4e48\u3001\u5165\u53e3\u670d\u52a1\u662f\u54ea\u4e00\u4e2a\u3002\u771f\u6b63\u7684\u4e1a\u52a1\u89c4\u5219\u653e\u5230\u670d\u52a1\u5c42&#xff0c;\u4e0d\u653e\u5728\u914d\u7f6e\u91cc\u3002<\/p>\n<h3>5. \u9002\u914d\u5c42\u8d1f\u8d23\u8f93\u5165\u548c\u9519\u8bef<\/h3>\n<p>\u9002\u914d\u5c42\u4e0d\u8981\u53ea\u5305\u4e00\u5c42\u540c\u540d\u65b9\u6cd5\u3002\u5b83\u8981\u5904\u7406\u7a7a\u8f93\u5165\u3001\u683c\u5f0f\u5f52\u4e00\u5316\u3001\u9519\u8bef\u8f6c\u6362\u548c\u8fd4\u56de\u7ed3\u6784\u3002\u8fd9\u6837\u9875\u9762\u62ff\u5230\u7684\u7ed3\u679c\u624d\u7a33\u5b9a\u3002<\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">interface<\/span> <span class=\"token class-name\">GrpcClientServiceResult<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  ok<span class=\"token operator\">:<\/span> <span class=\"token builtin\">boolean<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  message<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  latencyMs<span class=\"token operator\">:<\/span> <span class=\"token builtin\">number<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">GrpcClientAdapter<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">normalize<\/span><span class=\"token punctuation\">(<\/span>raw<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> value <span class=\"token operator\">&#061;<\/span> raw<span class=\"token punctuation\">.<\/span><span class=\"token function\">trim<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>value<span class=\"token punctuation\">.<\/span>length <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">throw<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">Error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;RPC \u8bf7\u6c42\u4e0d\u80fd\u4e3a\u7a7a&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> value<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token function\">execute<\/span><span class=\"token punctuation\">(<\/span>raw<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> GrpcClientServiceResult <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> value <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">normalize<\/span><span class=\"token punctuation\">(<\/span>raw<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      ok<span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      message<span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\u6d41\u5f0f\u56de\u8c03\u5b8c\u6210: &#039;<\/span> <span class=\"token operator\">&#043;<\/span> value<span class=\"token punctuation\">,<\/span><br \/>\n      latencyMs<span class=\"token operator\">:<\/span> value<span class=\"token punctuation\">.<\/span>length<br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u4fdd\u62a4\u7684\u662f\u4e1a\u52a1\u8fb9\u754c\u3002\u4e09\u65b9\u5e93\u53ef\u4ee5\u53d8\u5316&#xff0c;\u4f46\u9875\u9762\u548c\u4e0a\u5c42\u670d\u52a1\u53ea\u4f9d\u8d56 GrpcClientServiceResult&#xff0c;\u4e0d\u4f1a\u88ab\u5e95\u5c42\u53c2\u6570\u7ed3\u6784\u62d6\u7740\u6539\u3002<\/p>\n<h3>6. \u670d\u52a1\u5c42\u627f\u63a5\u4e1a\u52a1\u8bed\u4e49<\/h3>\n<p>\u670d\u52a1\u5c42\u8981\u628a\u9002\u914d\u5c42\u7ed3\u679c\u53d8\u6210\u4e1a\u52a1\u80fd\u76f4\u63a5\u6d88\u8d39\u7684\u72b6\u6001\u3002\u5b83\u53ef\u4ee5\u8bb0\u5f55\u6765\u6e90\u3001\u8865\u9ed8\u8ba4\u503c\u3001\u63a7\u5236\u91cd\u8bd5&#xff0c;\u4f46\u4e0d\u8981\u628a\u9875\u9762\u72b6\u6001\u548c\u4e09\u65b9\u5e93\u7ec6\u8282\u6df7\u5728\u4e00\u8d77\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> GrpcClientAdapter<span class=\"token punctuation\">,<\/span> GrpcClientServiceResult <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;..\/adapter\/GrpcClientAdapter&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">GrpcClientService<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">private<\/span> adapter <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">GrpcClientAdapter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span>raw<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> GrpcClientServiceResult <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">try<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">return<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>adapter<span class=\"token punctuation\">.<\/span><span class=\"token function\">execute<\/span><span class=\"token punctuation\">(<\/span>raw<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">catch<\/span> <span class=\"token punctuation\">(<\/span>err<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        ok<span class=\"token operator\">:<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        message<span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span>err <span class=\"token keyword\">as<\/span> Error<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>message<span class=\"token punctuation\">,<\/span><br \/>\n        latencyMs<span class=\"token operator\">:<\/span> <span class=\"token number\">0<\/span><br \/>\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u670d\u52a1\u5c42\u7684\u8f93\u5165\u6765\u81ea\u9875\u9762\u6216\u4e1a\u52a1\u6d41\u7a0b&#xff0c;\u8f93\u51fa\u7528\u4e8e\u5c55\u793a\u3001\u7f13\u5b58\u6216\u63d0\u4ea4\u3002\u540e\u7eed\u66ff\u6362\u4e09\u65b9\u5e93\u65f6&#xff0c;\u53ea\u8981\u670d\u52a1\u5c42\u5951\u7ea6\u7a33\u5b9a&#xff0c;\u4e1a\u52a1\u8c03\u7528\u65b9\u5c31\u4e0d\u7528\u5927\u9762\u79ef\u6539\u52a8\u3002<\/p>\n<h3>7. \u9875\u9762\u9a8c\u6536\u5165\u53e3\u8981\u53ef\u91cd\u590d<\/h3>\n<p>\u793a\u4f8b\u9875\u662f\u6587\u7ae0\u53ef\u4fe1\u5ea6\u7684\u4e00\u90e8\u5206\u3002\u8bfb\u8005\u9700\u8981\u770b\u5230\u8f93\u5165\u3001\u6309\u94ae\u3001\u7ed3\u679c\u548c\u5f02\u5e38\u4fe1\u606f\u5982\u4f55\u4e32\u8d77\u6765&#xff0c;\u800c\u4e0d\u662f\u53ea\u770b\u5230\u4e00\u6bb5\u5b64\u7acb\u4ee3\u7801\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> GrpcClientService <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;..\/service\/GrpcClientService&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Entry<\/span><\/span><br \/>\n<span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Component<\/span><\/span><br \/>\nstruct GrpcClientServicePage <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">State<\/span><\/span> input<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;grpc-client-input&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">State<\/span><\/span> output<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\u7b49\u5f85\u8fd0\u884c&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">private<\/span> service <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">GrpcClientService<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token function\">build<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">Column<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> space<span class=\"token operator\">:<\/span> <span class=\"token number\">12<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token function\">TextInput<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> text<span class=\"token operator\">:<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>input<span class=\"token punctuation\">,<\/span> placeholder<span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\u8f93\u5165RPC \u8bf7\u6c42&#039;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">onChange<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>value<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>input <span class=\"token operator\">&#061;<\/span> value<span class=\"token punctuation\">)<\/span><br \/>\n      <span class=\"token function\">Button<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;\u6267\u884c\u6d41\u5f0f\u56de\u8c03&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">onClick<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n          <span class=\"token keyword\">const<\/span> result <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>service<span class=\"token punctuation\">.<\/span><span class=\"token function\">run<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>input<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n          <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>output <span class=\"token operator\">&#061;<\/span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">&#096;<\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>result<span class=\"token punctuation\">.<\/span>ok<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token string\"> \/ <\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>result<span class=\"token punctuation\">.<\/span>message<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token string\"> \/ latencyMs&#061;<\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>result<span class=\"token punctuation\">.<\/span>latencyMs<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token template-punctuation string\">&#096;<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n      <span class=\"token function\">Text<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>output<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">fontSize<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">14<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span><span class=\"token function\">padding<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">20<\/span><span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u9875\u9762\u9a8c\u6536\u8981\u8986\u76d6\u6b63\u5e38\u8f93\u5165\u548c\u7a7a\u8f93\u5165\u3002\u7a7a\u8f93\u5165\u80fd\u5426\u88ab\u660e\u786e\u63d0\u793a&#xff0c;\u80fd\u76f4\u63a5\u53cd\u6620\u9002\u914d\u5c42\u662f\u5426\u771f\u6b63\u627f\u62c5\u4e86\u8fb9\u754c\u4fdd\u62a4\u3002<\/p>\n<h3>8. Native \u6216\u5e95\u5c42\u8c03\u7528\u8fb9\u754c<\/h3>\n<p>\u5982\u679c\u5e93\u6709 Native\u3001SDK \u6216\u7cfb\u7edf\u80fd\u529b\u8c03\u7528&#xff0c;\u9700\u8981\u518d\u5355\u72ec\u5199\u4e00\u5c42\u5e95\u5c42\u5305\u88c5\u3002\u5e95\u5c42\u5305\u88c5\u53ea\u8d1f\u8d23\u8c03\u7528 callUnary\u3001\u8f6c\u6362\u7ed3\u679c\u548c\u91ca\u653e\u8d44\u6e90&#xff0c;\u4e0d\u627f\u62c5\u9875\u9762\u903b\u8f91\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">NativeResult<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">bool<\/span> ok<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> value<span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>string message<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>NativeResult <span class=\"token function\">RunGrpcClientService<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">const<\/span> std<span class=\"token double-colon punctuation\">::<\/span>string <span class=\"token operator\">&amp;<\/span>input<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>input<span class=\"token punctuation\">.<\/span><span class=\"token function\">empty<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;empty input&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> value <span class=\"token operator\">&#061;<\/span> <span class=\"token generic-function\"><span class=\"token function\">static_cast<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span><span class=\"token keyword\">int<\/span><span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>input<span class=\"token punctuation\">.<\/span><span class=\"token function\">size<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">,<\/span> value<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;callUnary completed&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u7684\u91cd\u70b9\u662f\u8fb9\u754c\u6e05\u6670\u3002Native \u5c42\u4e0d\u76f4\u63a5\u8fd4\u56de\u88f8\u6307\u9488\u3001\u4e0d\u8ba9\u9875\u9762\u5904\u7406\u9519\u8bef\u7801\u3001\u4e0d\u628a\u8d44\u6e90\u91ca\u653e\u4ea4\u7ed9\u8c03\u7528\u65b9\u731c\u6d4b\u3002<\/p>\n<h3>9. \u547d\u4ee4\u884c\u9a8c\u8bc1\u8981\u7ed9\u8bfb\u8005\u8def\u5f84<\/h3>\n<p>\u6587\u7ae0\u91cc\u7684\u547d\u4ee4\u4e0d\u9700\u8981\u591a&#xff0c;\u4f46\u8981\u80fd\u5e2e\u8bfb\u8005\u5b9a\u4f4d\u95ee\u9898\u3002\u5305\u7ba1\u7406\u3001\u6784\u5efa\u4ea7\u7269\u3001\u8fd0\u884c\u65e5\u5fd7\u662f\u4e09\u7c7b\u6700\u5e38\u7528\u8bc1\u636e\u3002<\/p>\n<p>ohpm list <span class=\"token parameter variable\">&#8211;all<\/span><\/p>\n<p>hvigorw <span class=\"token parameter variable\">&#8211;mode<\/span> module <span class=\"token parameter variable\">-p<\/span> <span class=\"token assign-left variable\">module<\/span><span class=\"token operator\">&#061;<\/span>entry assembleHap<\/p>\n<p>hdc hilog <span class=\"token operator\">|<\/span> findstr grpc_client<\/p>\n<p>\u6267\u884c\u540e\u5efa\u8bae\u8bb0\u5f55\u4e09\u9879\u7ed3\u679c&#xff1a;\u4f9d\u8d56\u7248\u672c\u662f\u5426\u7b26\u5408\u9884\u671f\u3001HAP \u662f\u5426\u80fd\u6784\u5efa\u3001\u793a\u4f8b\u9875\u89e6\u53d1\u65f6\u662f\u5426\u6709\u660e\u786e\u65e5\u5fd7\u3002\u8fd9\u6837\u540e\u7eed\u6362\u7248\u672c\u65f6\u53ef\u4ee5\u76f4\u63a5\u5bf9\u6bd4\u3002<\/p>\n<h3>10. \u5e38\u89c1\u95ee\u9898\u6392\u67e5<\/h3>\n<table>\n<tr>\u73b0\u8c61\u5e38\u89c1\u539f\u56e0\u5904\u7406\u65b9\u5f0f<\/tr>\n<tbody>\n<tr>\n<td>\u9875\u9762\u6ca1\u6709\u7ed3\u679c<\/td>\n<td>\u670d\u52a1\u5c42\u541e\u6389\u9519\u8bef\u6216\u6ca1\u6709\u5237\u65b0\u72b6\u6001<\/td>\n<td>\u8fd4\u56de ok\/message \u5e76\u5c55\u793a\u5230\u793a\u4f8b\u9875<\/td>\n<\/tr>\n<tr>\n<td>\u6784\u5efa\u5931\u8d25<\/td>\n<td>\u7248\u672c\u3001\u8def\u5f84\u6216 ABI \u4e0d\u4e00\u81f4<\/td>\n<td>\u56de\u5230\u4f9d\u8d56\u5165\u53e3\u6838\u5bf9\u5b9e\u9645\u4ea7\u7269<\/td>\n<\/tr>\n<tr>\n<td>\u771f\u673a\u5f02\u5e38<\/td>\n<td>\u6743\u9650\u3001\u6c99\u76d2\u6216\u8bbe\u5907\u80fd\u529b\u4e0d\u540c<\/td>\n<td>\u7528\u771f\u673a\u65e5\u5fd7\u786e\u8ba4\u5931\u8d25\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\u5347\u7ea7\u540e\u884c\u4e3a\u53d8\u5316<\/td>\n<td>\u4e09\u65b9\u5e93\u9ed8\u8ba4\u53c2\u6570\u53d8\u5316<\/td>\n<td>\u4fdd\u7559\u793a\u4f8b\u9875\u4f5c\u4e3a\u56de\u5f52\u5165\u53e3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6392\u67e5\u987a\u5e8f\u56fa\u5b9a\u4e3a\u914d\u7f6e\u3001\u6784\u5efa\u3001\u9002\u914d\u5c42\u3001\u9875\u9762\u5c42\u3002\u8fd9\u4e2a\u987a\u5e8f\u80fd\u907f\u514d\u4e00\u5f00\u59cb\u5c31\u6539 UI&#xff0c;\u6700\u540e\u624d\u53d1\u73b0\u662f\u4f9d\u8d56\u7248\u672c\u9519\u4e86\u3002<\/p>\n<h3>11. \u9a8c\u6536\u65ad\u8a00<\/h3>\n<p>\u9a8c\u6536\u65ad\u8a00\u628a\u201c\u80fd\u770b\u89c1\u6548\u679c\u201d\u53d8\u6210\u201c\u7ed3\u679c\u6ee1\u8db3\u5951\u7ea6\u201d\u3002\u4e0b\u9762\u7684\u65ad\u8a00\u53ef\u4ee5\u653e\u5728 smoke \u6d41\u7a0b\u91cc&#xff0c;\u4e5f\u53ef\u4ee5\u5728\u793a\u4f8b\u9875\u89e6\u53d1\u540e\u624b\u52a8\u6838\u5bf9\u3002<\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">assertGrpcClientServiceReady<\/span><span class=\"token punctuation\">(<\/span>result<span class=\"token operator\">:<\/span> GrpcClientServiceResult<span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>result<span class=\"token punctuation\">.<\/span>ok<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">throw<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">Error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token template-string\"><span class=\"token template-punctuation string\">&#096;<\/span><span class=\"token string\">gRPC\u5ba2\u6237\u7aef\u9002\u914d\u6267\u884c\u5931\u8d25: <\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>result<span class=\"token punctuation\">.<\/span>message<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token template-punctuation string\">&#096;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>result<span class=\"token punctuation\">.<\/span>latencyMs <span class=\"token operator\">&lt;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">throw<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">Error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token template-string\"><span class=\"token template-punctuation string\">&#096;<\/span><span class=\"token string\">latencyMs \u4e0d\u7b26\u5408\u9884\u671f: <\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>result<span class=\"token punctuation\">.<\/span>latencyMs<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token template-punctuation string\">&#096;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u6bb5\u65ad\u8a00\u7684\u4ef7\u503c\u5728\u5347\u7ea7\u65f6\u66f4\u660e\u663e\u3002\u53ea\u8981\u8fd4\u56de\u7ed3\u6784\u6216\u5173\u952e\u6307\u6807\u53d8\u4e86&#xff0c;\u95ee\u9898\u4f1a\u5728\u9a8c\u6536\u9636\u6bb5\u66b4\u9732&#xff0c;\u800c\u4e0d\u662f\u7b49\u5230\u4e1a\u52a1\u9875\u9762\u4e0a\u7ebf\u540e\u624d\u53d1\u73b0\u3002<\/p>\n<h3>12. \u5b8c\u6210\u524d\u6e05\u5355<\/h3>\n<ul>\n<li>\u4f9d\u8d56\u6765\u6e90\u3001\u7248\u672c\u548c\u8bb8\u53ef\u8bc1\u5df2\u8bb0\u5f55\u3002<\/li>\n<li>\u914d\u7f6e\u5165\u53e3\u3001\u9002\u914d\u5c42\u3001\u670d\u52a1\u5c42\u548c\u9875\u9762\u5c42\u804c\u8d23\u5206\u5f00\u3002<\/li>\n<li>\u793a\u4f8b\u9875\u80fd\u91cd\u590d\u89e6\u53d1 \u6d41\u5f0f\u56de\u8c03\u3002<\/li>\n<li>\u7a7a\u8f93\u5165\u3001\u5f02\u5e38\u8f93\u5165\u548c\u6b63\u5e38\u8f93\u5165\u90fd\u6709\u660e\u786e\u7ed3\u679c\u3002<\/li>\n<li>\u547d\u4ee4\u884c\u9a8c\u8bc1\u80fd\u5b9a\u4f4d\u4f9d\u8d56\u3001\u6784\u5efa\u548c\u65e5\u5fd7\u3002<\/li>\n<li>\u5e38\u89c1\u95ee\u9898\u8868\u80fd\u8986\u76d6\u8bfb\u8005\u6700\u53ef\u80fd\u9047\u5230\u7684\u5931\u8d25\u3002<\/li>\n<li>\u56fe\u7247\u3001\u56fe\u6ce8\u548c\u7ed3\u6784\u8bf4\u660e\u80fd\u5e2e\u52a9\u8bfb\u8005\u590d\u73b0\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4efd\u6e05\u5355\u5efa\u8bae\u6bcf\u6b21\u5347\u7ea7\u5e93\u7248\u672c\u540e\u91cd\u65b0\u6267\u884c\u3002\u5c24\u5176\u662f\u6d89\u53ca RPC \u8bf7\u6c42 \u548c \u6d41\u5f0f\u56de\u8c03 \u7684\u573a\u666f&#xff0c;\u4e0d\u80fd\u53ea\u770b\u6784\u5efa\u662f\u5426\u6210\u529f&#xff0c;\u8fd8\u8981\u786e\u8ba4\u9875\u9762\u72b6\u6001\u3001\u65e5\u5fd7\u8f93\u51fa\u548c\u9519\u8bef\u515c\u5e95\u90fd\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<h3>13. \u5c0f\u7ed3<\/h3>\n<p>gRPC\u5ba2\u6237\u7aef\u9002\u914d\u7684\u9002\u914d\u91cd\u70b9\u662f\u628a\u5e93\u80fd\u529b\u53d8\u6210\u9879\u76ee\u53ef\u7ef4\u62a4\u80fd\u529b\u3002\u6e90\u7801\u3001\u914d\u7f6e\u3001\u5c01\u88c5\u3001\u9875\u9762\u3001\u547d\u4ee4\u548c\u9a8c\u6536\u90fd\u5199\u6e05\u695a&#xff0c;\u8bfb\u8005\u624d\u80fd\u628a\u6587\u7ae0\u5185\u5bb9\u8fc1\u79fb\u5230\u81ea\u5df1\u7684\u5de5\u7a0b\u91cc&#xff0c;\u800c\u4e0d\u662f\u53ea\u5f97\u5230\u4e00\u4e2a\u65e0\u6cd5\u590d\u73b0\u7684\u793a\u4f8b\u3002<\/p>\n<h3>\u53c2\u8003\u8d44\u6599<\/h3>\n<ul>\n<li>OpenHarmony \u4e09\u65b9\u5e93\u4e2d\u5fc3\u4ed3<\/li>\n<li>HarmonyOS \u5f00\u53d1\u6587\u6863<\/li>\n<li>HarmonyOS Native \u5f00\u53d1\u4e0e\u4e09\u65b9\u5e93\u96c6\u6210 FAQ<\/li>\n<\/ul>\n<p>\u53c2\u8003\u8d44\u6599\u7528\u4e8e\u6838\u5bf9 API\u3001\u5e73\u53f0\u80fd\u529b\u548c\u6784\u5efa\u94fe\u8def\u3002\u6b63\u5f0f\u63a5\u5165\u524d&#xff0c;\u5e94\u7ed3\u5408\u5f53\u524d SDK\u3001\u4e09\u65b9\u5e93 README\u3001Release \u8bb0\u5f55\u548c\u9879\u76ee\u6743\u9650\u914d\u7f6e\u91cd\u65b0\u786e\u8ba4\u8fb9\u754c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c59\u7bc7&#xff5c;gRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS \u56fe 1&#xff1a;gRPC\u5ba2\u6237\u7aef\u9002\u914d\u5c01\u9762\u56fe&#xff0c;\u7528\u6765\u6982\u62ec\u672c\u6587\u4e3b\u9898\u3001\u9002\u914d\u5bf9\u8c61\u548c\u5de5\u7a0b\u8fb9\u754c\u3002<br \/>\ngRPC \u7c7b\u5e93\u9002\u914d\u8981\u540c\u65f6\u770b HTTP2\u3001\u8bc1\u4e66\u3001\u8d85\u65f6\u548c\u6d41\u5f0f\u56de\u8c03&#xff0c;\u4e0d\u9002\u5408\u53ea\u5199\u4e00\u4e2a\u8bf7\u6c42\u793a\u4f8b\u3002<br \/>\n\u672c\u6587\u56f4\u7ed5 RPC \u8bf7\u6c42 \u548c \u6d41\u5f0f\u56de\u8c03 \u5c55\u5f00&#xff0c;\u76ee\u6807\u4e0d\u662f\u628a\u5e93\u63a5\u8fdb\u5de5\u7a0b\u540e\u622a\u56fe\u7ed3\u675f&#xff0c;\u800c\u662f\u628a\u6765\u6e90\u3001\u7248\u672c\u3001\u914d\u7f6e\u3001\u5c01\u88c5\u3001\u8fd0\u884c\u548c\u9a8c\u6536\u5199\u6210\u4e00\u6761\u8bfb\u8005\u53ef\u4ee5\u590d\u73b0\u7684\u94fe\u8def\u3002 \u56fe 2&#xff1a;gRPC<\/p>\n","protected":false},"author":2,"featured_media":102655,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[84,280,1693],"topic":[],"class_list":["post-102658","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-android","tag-harmonyos","tag-kotlin"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/102658.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7b2c59\u7bc7&#xff5c;gRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS \u56fe 1&#xff1a;gRPC\u5ba2\u6237\u7aef\u9002\u914d\u5c01\u9762\u56fe&#xff0c;\u7528\u6765\u6982\u62ec\u672c\u6587\u4e3b\u9898\u3001\u9002\u914d\u5bf9\u8c61\u548c\u5de5\u7a0b\u8fb9\u754c\u3002 gRPC \u7c7b\u5e93\u9002\u914d\u8981\u540c\u65f6\u770b HTTP2\u3001\u8bc1\u4e66\u3001\u8d85\u65f6\u548c\u6d41\u5f0f\u56de\u8c03&#xff0c;\u4e0d\u9002\u5408\u53ea\u5199\u4e00\u4e2a\u8bf7\u6c42\u793a\u4f8b\u3002 \u672c\u6587\u56f4\u7ed5 RPC \u8bf7\u6c42 \u548c \u6d41\u5f0f\u56de\u8c03 \u5c55\u5f00&#xff0c;\u76ee\u6807\u4e0d\u662f\u628a\u5e93\u63a5\u8fdb\u5de5\u7a0b\u540e\u622a\u56fe\u7ed3\u675f&#xff0c;\u800c\u662f\u628a\u6765\u6e90\u3001\u7248\u672c\u3001\u914d\u7f6e\u3001\u5c01\u88c5\u3001\u8fd0\u884c\u548c\u9a8c\u6536\u5199\u6210\u4e00\u6761\u8bfb\u8005\u53ef\u4ee5\u590d\u73b0\u7684\u94fe\u8def\u3002 \u56fe 2&#xff1a;gRPC\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/102658.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-09T02:41:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260909024113-6aa0c749979a6.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102658.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/102658.html\",\"name\":\"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-09T02:41:16+00:00\",\"dateModified\":\"2026-09-09T02:41:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/102658.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/102658.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/102658.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/102658.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7b2c59\u7bc7&#xff5c;gRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS \u56fe 1&#xff1a;gRPC\u5ba2\u6237\u7aef\u9002\u914d\u5c01\u9762\u56fe&#xff0c;\u7528\u6765\u6982\u62ec\u672c\u6587\u4e3b\u9898\u3001\u9002\u914d\u5bf9\u8c61\u548c\u5de5\u7a0b\u8fb9\u754c\u3002 gRPC \u7c7b\u5e93\u9002\u914d\u8981\u540c\u65f6\u770b HTTP2\u3001\u8bc1\u4e66\u3001\u8d85\u65f6\u548c\u6d41\u5f0f\u56de\u8c03&#xff0c;\u4e0d\u9002\u5408\u53ea\u5199\u4e00\u4e2a\u8bf7\u6c42\u793a\u4f8b\u3002 \u672c\u6587\u56f4\u7ed5 RPC \u8bf7\u6c42 \u548c \u6d41\u5f0f\u56de\u8c03 \u5c55\u5f00&#xff0c;\u76ee\u6807\u4e0d\u662f\u628a\u5e93\u63a5\u8fdb\u5de5\u7a0b\u540e\u622a\u56fe\u7ed3\u675f&#xff0c;\u800c\u662f\u628a\u6765\u6e90\u3001\u7248\u672c\u3001\u914d\u7f6e\u3001\u5c01\u88c5\u3001\u8fd0\u884c\u548c\u9a8c\u6536\u5199\u6210\u4e00\u6761\u8bfb\u8005\u53ef\u4ee5\u590d\u73b0\u7684\u94fe\u8def\u3002 \u56fe 2&#xff1a;gRPC","og_url":"https:\/\/www.wsisp.com\/helps\/102658.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-09T02:41:16+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260909024113-6aa0c749979a6.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/102658.html","url":"https:\/\/www.wsisp.com\/helps\/102658.html","name":"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-09T02:41:16+00:00","dateModified":"2026-09-09T02:41:16+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/102658.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/102658.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/102658.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b2c59\u7bc7\uff5cgRPC \u5ba2\u6237\u7aef\u5e93\u9002\u914d HarmonyOS"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=102658"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/102658\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/102655"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=102658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=102658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=102658"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=102658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}