WSO2 Enterprise Integrator无法调用已部署的API

时间:2019-06-13 10:48:16

标签: json xml rest api wso2esb

我对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资源的属性如下:

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文档,特别是集成教程“向服务发送简单消息”来创建该项目,以供参考:https://docs.wso2.com/display/EI650/Sending+a+Simple+Message+to+a+Service

非常感谢您的帮助。

预先感谢

亲切的问候

1 个答案:

答案 0 :(得分:0)

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