如何通过Postman在WSO2微集成器中发出gRPC请求?

问题描述 投票:0回答:1

我正在尝试通过 Postman 在 WSO2 微集成器中发出请求。

我正在使用此端点(这部分代码)来发出 gRPC 请求 https://github.com/wso2/micro-integrator/tree/master/components/mediation/inbound-endpoints/org.wso2.micro.integrator.inbound.endpoint/src/main/java/org/wso2/carbon/入站/端点/协议/grpc

我初始化端点的步骤:

  1. 我手动将入站端点创建为 XML 文件并将其保存在目录中。然后我运行应用程序

grpcInboundEndpoint.xml:

<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="GrpcInboundEndpoint" sequence="inSeq" onError="fault" protocol="grpc" suspend="false">
    <parameters>
        <parameter name="inbound.grpc.port">8888</parameter>
    </parameters>
</inboundEndpoint>

目录: /存储库/部署/服务器/synapse-configs/默认/入站端点

  1. 我通过邮递员提出请求。为了发出请求,我使用这个 Protobuf 文件(我可以找到): https://github.com/slahirucd7/siddhi_with_grpc/blob/927eb13e7d3eaa21ea3eba9007e34593eadfdcd7/src/main/proto/EventService.proto

为了向 EventService.process 方法发出请求,我使用以下示例消息:

{
    "headers": {},
    "payload": "test"
}
  1. 根据请求,我在 shell 中看到 NullPointerException:
[2024-03-29 14:15:48,233] ERROR {io.grpc.internal.SerializingExecutor} -  - Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@547800d3 java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
    at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1535)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectInbound(Axis2SynapseEnvironment.java:423)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.GRPCInjectHandler.initiateSequenceAndInjectPayload(GRPCInjectHandler.java:138)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.GRPCInjectHandler.invokeProcess(GRPCInjectHandler.java:84)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.InboundGRPCListener$1.process(InboundGRPCListener.java:84)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.util.EventServiceGrpc$MethodHandlers.invoke(EventServiceGrpc.java:290)
    at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
    at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:351)
    at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:861)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

状态代码:2未知 时间:28 毫秒

EventService.proto 文件似乎没有足够的信息来发出工作请求,或者我最终不明白如何在 WSO2 微集成器中发出 gRPC 请求。

wso2 wso2-esb wso2-api-manager wso2-enterprise-integrator wso2-micro-integrator
1个回答
0
投票

我的问题的答案是 - 如果您需要请求 gRPC 服务,您必须使用这些数据(或类似数据)发送请求:

{
    "headers": {"Content-Type":"json"},
    "payload": "{\"test\":\"yes\"}"
}

你会看到这样的回复:

{
    "headers": {},
    "payload": "{\"test\":\"yes\"}"
}
© www.soinside.com 2019 - 2024. All rights reserved.