使用 WSO2 ESB 错误调用 RESTFul API
Invoke RESTFul API using WSO2 ESB error
我正在尝试使用 WSO2 ESB 调用一个简单的 RESTFul API POST 用户名和密码,但是当我尝试使用邮递员调用它时没有得到响应:
RESTFulAPIURL是:http://{REST service IP:port}/api/signup
从 ESB 调用的 URL 是 http://{ESP IP:PORT}/api1/signup
我在 WSO2 ESB 中所做的 API 配置是
<api xmlns="http://ws.apache.org/ns/synapse" name="API_TEST" context="/api1">
<resource methods="POST" url-mapping="/signup">
<inSequence>
<log/>
<send>
<endpoint>
<address uri="http://< REST service IP:port>/api/signup"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</resource>
</api>
我发布了一个简单的 JSON 元素:
{
"name":"adnan",
"password":"adnan1"
}
WSO2 控制台显示以下消息:
INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:8073ca47-1ea3-4232-bcb7-4f947bca6591, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Error while building message, Envelope:
如果您在 post body 中发送 json,您需要从您的客户端设置 Content-Type: application/json header。
添加上一个答案-:
对于 GET
请求这有效 fine.but POST
请求您需要为其余客户端指定 Content-Type:application/json header。
我解决了:我编辑了 URI-Mapping tp“/”并编辑了 LOG 介体。
<api xmlns="http://ws.apache.org/ns/synapse" name="API_TEST"context="/api1">
<resource methods="POST" url-mapping="/">
<inSequence>
<send>
<endpoint>
<address uri="http://{ESB IP:PORT}/api/signup"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
我正在尝试使用 WSO2 ESB 调用一个简单的 RESTFul API POST 用户名和密码,但是当我尝试使用邮递员调用它时没有得到响应:
RESTFulAPIURL是:http://{REST service IP:port}/api/signup
从 ESB 调用的 URL 是 http://{ESP IP:PORT}/api1/signup
我在 WSO2 ESB 中所做的 API 配置是
<api xmlns="http://ws.apache.org/ns/synapse" name="API_TEST" context="/api1">
<resource methods="POST" url-mapping="/signup">
<inSequence>
<log/>
<send>
<endpoint>
<address uri="http://< REST service IP:port>/api/signup"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log/>
<send/>
</outSequence>
</resource>
</api>
我发布了一个简单的 JSON 元素:
{
"name":"adnan",
"password":"adnan1"
}
WSO2 控制台显示以下消息:
INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:8073ca47-1ea3-4232-bcb7-4f947bca6591, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Error while building message, Envelope:
如果您在 post body 中发送 json,您需要从您的客户端设置 Content-Type: application/json header。
添加上一个答案-:
对于 GET
请求这有效 fine.but POST
请求您需要为其余客户端指定 Content-Type:application/json header。
我解决了:我编辑了 URI-Mapping tp“/”并编辑了 LOG 介体。
<api xmlns="http://ws.apache.org/ns/synapse" name="API_TEST"context="/api1">
<resource methods="POST" url-mapping="/">
<inSequence>
<send>
<endpoint>
<address uri="http://{ESB IP:PORT}/api/signup"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>