【发布时间】: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'并且每个端点似乎都可以运行并成功输出。我将按照建议启用线路日志并返回结果