我正在尝试使用WSO2 ESB调用POST用户名和密码的简单RESTFul API,但在尝试使用postman调用它时我没有得到响应:
RESTFul API网址为: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&#39; fault&# 39;序列,ERROR_CODE = 0,ERROR_MESSAGE =构建消息时出错,信封:
答案 0 :(得分:1)
如果您要在帖子正文中发送json,则需要从您的客户端设置Content-Type:application / json标头。
答案 1 :(得分:0)
添加上一个答案 - :
对于ink_id
请求,这工作正常。但GET
请求您需要为其余客户端指定Content-Type:application / json标头。
答案 2 :(得分:0)
我解决了它:我编辑了URI-Mapping tp&#34; /&#34;并编辑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>