【问题标题】:WSO2 Enterprise Integrator Unable to call deployed APIWSO2 Enterprise Integrator 无法调用已部署的 API
【发布时间】:2019-06-13 10:48:16
【问题描述】:

我对 WSO2 完全陌生,我正面临下面描述的问题。

部署 API(复合应用程序 *.car 文件)后,我无法从 WSO2 ESB 调用已定义端点的服务。

我尝试调用的 REST API 部署在本地 tomcat 安装上,位于:

http://localhost:8080/CustomerInfoRestService/customers/

要检索 json 客户对象,我只需添加客户 ID,如下所示:

http://localhost:8080/CustomerInfoRestService/customers/2

所有服务操作(Get、POST、PUT、DELETE)都经过测试并成功调用。为了进行测试,我使用了“PostMan”工具。

我使用 WSO2 Integration Studio 创建了一个 ESB 项目。

首先,我使用以下 URI 模板定义了一个端点: http://localhost:8080/CustomerInfoRestService/customers/{uri.var.custId}

然后我定义了一个 REST API。 API Resource的属性如下:

URL-Style: URI_Template

URI-Template: /customers/{custId}

Methods: GET

在顺序中,我添加了一个日志中介,具有:

Log Category: INFO
Log Level: CUSTOM

我将它的信息定义为:

Property Name: message
Property value type: LITERAL
Property Value: Welcome to Customer Service

直接在日志中介旁边是一个“发送”中介,我在上面包含了定义的端点。

然后我将复合应用程序部署为:右键单击 -> 导出复合应用程序项目。

我在生成的 *.car 文件中同时包含 API 和端点。

现在要调用 API 请求,我使用“curl”调用服务:

curl -v http://localhost:8280/CustomerInfoRestService/customers/2

我得到了回应:

*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8280 (#0)
> GET /CustomerInfoRestService/customers/2 HTTP/1.1
> Host: localhost:8280
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Thu, 13 Jun 2019 10:09:06 GMT
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact

好像没找到(404错误)

我按照 WSO2 文档,特别是集成教程“Sending a Simple Message to a Service”来创建这个项目,供参考:https://docs.wso2.com/display/EI650/Sending+a+Simple+Message+to+a+Service

非常感谢任何帮助。

提前致谢,

亲切的问候,

【问题讨论】:

  • 你的 API 的上下文是什么?是“/CustomerInfoRestService”吗?您的 API 是否有版本类型?喜欢上下文或网址?
  • 很抱歉之前没有提及此信息。 api名称为“CustomerInfoAPI”,上下文为“/CustomerInfoRestService”,版本类型“none”
  • 您遵循的步骤似乎很好。但是让我们通过启用wirelogs来验证404是EI还是tomcat Rest API抛出的-docs.wso2.com/display/EI650/…如果是EI,请分享您的API和端点配置(删除任何敏感信息后)。
  • 感谢您的支持。实际上我已经测试了tomcat Rest API(通过chrome工具'Postman'并且每个端点似乎都可以运行并成功输出。我将按照建议启用线路日志并返回结果

标签: json xml rest api wso2esb


【解决方案1】:

当 API 未在 ESB 中部署或处于活动状态时,会出现这种响应。您是否部署了您创建的汽车文件?你没有在你的步骤中提到这一点。请确保您能够在管理控制台中看到 API(主页 -> 服务总线 -> API)。

【讨论】:

  • 嗨阿鲁南。我已按照建议检查了 EI 管理控制台,API 已成功部署,调用 URL 指定为:192.168.0.192/customerService:8280。有启用跟踪和启用统计等选项。使用这些功能进行故障排除是否有帮助?提前感谢您的支持
  • 您在这里提到的 URL 是 192.168.0.192/customerService:8280。但是您正在尝试调用localhost:8280/CustomerInfoRestService{resource-path}。对吗?
猜你喜欢
  • 2018-04-15
  • 2021-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多