从WSO2调用node.js api

我试图从WSO2 Api Mgmt本地configuration调用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中的debuggingfunction,发现由于控制台中显示了一些非常长的exception转储,调用从未到达node.js端点。

我正在使用WSO2前面的授权标题,它似乎工作正常。

虽然我在node.js中做了一些工作,但是对于WSO2来说,我是超新的。 所以任何帮助将不胜感激。

编辑:我使用下面给出的WSO2 API控制台使用WSO2 AM 1.9.0响应体 –

<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> 

编辑: APIpipe理器日志

 [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 curl -X GET -header“Accept:application / json”–header“Authorization:Bearer 6a931d4fb2f6c85be750ee7cea8bc094”“ https:// localhost:9443 / api / v1 / users ”

请求URL https:// localhost:9443 / api / v1 / users

响应代码405响应头{“date”:“Tue,23 Jun 2015 09:05:49 GMT”,“server”:“WSO2 Carbon Server”,“content-type”:“text / html; charset = utf-8 “,”content-length“:”1065“,”content-language“:”en“}

您必须在提供端点地址的同时检查GETcheckbox的值

使用这个API序列

 <?xml version="1.0" encoding="UTF-8"?> <api xmlns="http://ws.apache.org/ns/synapse" name="nodejsAPI" context="/api"> <resource methods="GET" protocol="http" uri-template="/v1/users"> <inSequence> <log level="full"/> <send> <endpoint> <http method="GET" uri-template="http://localhost:3000/users/"/> </endpoint> </send> </inSequence> <outSequence> <send/> </outSequence> <faultSequence/> </resource> </api> 

您的API创build可能有一些问题,因此它尚未正确映射到您的NodeJS REST端点。

在API创build向导中,您可以selecttestingAPI-M是否可以访问您的端点。 这一步可以validation连接没有问题。

我已经为您的使用案例逐步撰写了一篇博客文章 。 请按照这些步骤,并希望它应该工作。

确保URL模式字段和生产端点字段具有正确的值。