Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Implementation Procedure

Updated on 2025-01-16 GMT+08:00

Prerequisites

  • Both the client and server are of the gRPC type.
  • The server has a proto file that defines API request and response parameters. The proto file is used in gRPC to define data structures and service APIs. It describes data structures and interactions using Protobuf and serves as a contract for communication between the client and server.

Creating an API

  1. Log in to the APIG console.
  2. Select a gateway at the top of the navigation pane.
  3. In the navigation pane, choose API Management > APIs.
  4. Click Create API > Create gRPC API. For details, see Creating a gRPC API.
  5. Configure the frontend information according to the following table. Click Next.

    Table 1 Frontend configuration

    Parameter

    Description

    API Name

    Enter an API name.

    Group

    Group to which the API belongs. The default value is DEFAULT.

    URL

    • Method: Request method of the API. Default: POST.
    • Protocol: Request protocol of the API. Default: GRPCS.
    • Subdomain Name: The system automatically allocates a subdomain name to each API group for internal testing. The subdomain name can be accessed 1,000 times a day.
    • Path: Path for requesting the API. In this example, enter /helloworld.Greeter. For details about the request path, see the proto file. helloworld indicates the package name, and Greeter indicates the service name.

    Gateway Response

    Select a response to be displayed if the gateway fails to process an API request.

    The default gateway response is default.

    Matching

    Select Prefix match.

    Authentication Mode

    API authentication mode. Select None. (None: Not recommended for actual services. All users will be granted access to the API.)

  6. Configure the backend information according to the following table. Click Finish.

    Table 2 Backend configuration

    Parameter

    Description

    Load Balance Channel

    Determine whether the backend service will be accessed using a load balance channel. For this example, select Skip.

    URL

    • Method: Request method of the API. Default: POST.
    • Protocol: Request protocol of the backend service. Default: GRPCS.
    • Backend Address: Address and port of the backend service.
    • Path: Path of the backend service. In this example, enter /.

Publishing the API

  1. On the APIs tab, select the created API and click Publish Latest Version.

    NOTE:

    On the APIs page, the API URL only shows the domain name and path. It does not show the request method or protocol. When sending a gRPC request, enter the domain name.

  2. Select the environment where the API will be published, and enter a description.
  3. Click OK. After the API is published, the red exclamation mark (!) in the upper left corner of the Publish button disappears.

Verifying the API

Use the API test tool to invoke the created API, or invoke this API on a client.

  1. Enter the debugging domain name of the API's group.
  2. Import the proto file of the server.

    The proto file contains the following content:
    syntax = "proto3";
    package helloworld;
    // The greeting service definition.
    service Greeter {
    // Sends a greeting
    rpc SayHello (HelloRequest) returns (HelloReply) {}
    }
    // The request message containing the user's name.
    message HelloRequest {
    string name = 1;
    }
    // The response message containing the greetings
    message HelloReply {
    string message = 1;
    } 
    • helloworld: package name
    • Greeter: service name
    • SayHello: method name
    • HelloRequest: request body
    • HelloReply: response body

  3. Enter an API request in the message area according to the proto file.

    {
        "name": "world"
    }

  4. Click Invoke to send the request.
  5. View the response in the Response area. If status code 0 OK is displayed, the invocation is successful.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback