【发布时间】:2015-09-08 20:36:04
【问题描述】:
我正在尝试从 WSO2 Api Mgmt 本地配置调用 node.js REST api (http://localhost:3000/users),但它不起作用。 node.js REST api 在浏览器/邮递员中运行良好。从 WSO2 调用时,它返回空响应。
从 WSO2 AM 公开的端点是 http://localhost:801/api/v1/users,它应该调用 node.js REST api。我尝试使用 WSO2 中的调试功能,发现调用永远不会到达 node.js 端点,因为控制台中显示了一些非常长的异常转储。
我在 WSO2 前端使用 Authorization 标头,它似乎工作正常。
虽然我在 node.js 中工作过一些,但我对 WSO2 还是很陌生。因此,我们将不胜感激任何帮助。
编辑:我使用的是 WSO2 AM 1.9.0 来自 WSO2 API 控制台的响应正文如下 -
<html>
<head>
<title>Apache Tomcat/7.0.55 - Error report</title>
<style>
<!
--H1
{
font-family: Tahoma,Arial,sans-serif;
color: white;
background-color: #525D76;
font-size: 22px;
}
H2
{
font-family: Tahoma,Arial,sans-serif;
color: white;
background-color: #525D76;
font-size: 16px;
}
H3
{
font-family: Tahoma,Arial,sans-serif;
color: white;
background-color: #525D76;
font-size: 14px;
}
BODY
{
font-family: Tahoma,Arial,sans-serif;
color: black;
background-color: white;
}
B
{
font-family: Tahoma,Arial,sans-serif;
color: white;
background-color: #525D76;
}
P
{
font-family: Tahoma,Arial,sans-serif;
background: white;
color: black;
font-size: 12px;
}
A
{
color: black;
}
A.name
{
color: black;
}
HR
{
color: #525D76;
}
-- ></style>
</head>
<body>
<h1>
HTTP Status 405 - HTTP method GET is not supported by this URL</h1>
<hr size="1" noshade="noshade">
<p>
<b>type</b> Status report</p>
<p>
<b>message</b> <u>HTTP method GET is not supported by this URL</u></p>
<p>
<b>description</b> <u>The specified HTTP method is not allowed for the requested resource.</u></p>
<hr size="1" noshade="noshade">
<h3>
Apache Tomcat/7.0.55</h3>
</body>
</html>
编辑: API 管理器日志
[2015-06-23 14:36:04,903] INFO - HandlerUtils Massage Info: Transaction id=1499
743816386524554259 Message direction=IN Server name=192.168.1.5:9763 Timestam
p=1435050364903 Service name=__SynapseService Operation Name=mediate
[2015-06-23 14:36:04,906] DEBUG - HTTPEndpoint Sending message through endpoint
: admin--GetUsers_APIproductionEndpoint_0 resolving to address = http://127.0.0.
1:3000/users
[2015-06-23 14:36:04,909] DEBUG - HTTPEndpoint SOAPAction: null
[2015-06-23 14:36:04,910] DEBUG - HTTPEndpoint WSA-Action: null
[2015-06-23 14:36:04,926] INFO - HandlerUtils Massage Info: Transaction id=1499
743816386524554259 Message direction=OUT Server name=192.168.1.5:9763 Timesta
mp=1435050364926 Service name=__SynapseService Operation Name=mediate
编辑: API 日志中的剩余详细信息
卷曲 curl -X GET --header "Accept: application/json" --header "Authorization: Bearer 6a931d4fb2f6c85be750ee7cea8bc094" "https://localhost:9443/api/v1/users"
请求网址 https://localhost:9443/api/v1/users
响应代码 405 响应标头 { "date": "2015 年 6 月 23 日星期二 09:05:49 GMT", "server": "WSO2 Carbon 服务器", “内容类型”:“文本/html;charset=utf-8”, “内容长度”:“1065”, “内容语言”:“en” }
【问题讨论】:
-
请在此处附上错误日志,以便我们为您提供帮助。
-
在上面添加了 API 控制台响应。
-
在上面添加了 API Manager 日志
-
能否附上 API 控制台的屏幕截图?另外,您能否通过 Postman cREST 客户端调用此 API?
-
不,我已经退出了这个项目 :)
标签: node.js api rest wso2 wso2-am