简体   繁体   English

使用 WSO2 ESB 错误调用 RESTFul API

[英]Invoke RESTFul API using WSO2 ESB error

I am trying to invoke a simple RESTFul API that POST username and password using WSO2 ESB, but i did not get response when trying to invoke it using postman:我正在尝试调用一个简单的 RESTFul API,该 API 使用 WSO2 ESB POST 用户名和密码,但在尝试使用邮递员调用它时没有得到响应:

the RESTFul API URL is: http://{REST service IP:port}/api/signup RESTFul API URL 是: http://{REST service IP:port}/api/signup

the URL to call from ESB is http://{ESP IP:PORT}/api1/signup从 ESB 调用的 URL 是http://{ESP IP:PORT}/api1/signup

the API Configuration i made in the WSO2 ESB is我在 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>

I posted a Simple JSON elements:我发布了一个简单的 JSON 元素:

{
  "name":"adnan",
  "password":"adnan1"
} 

the WSO2 Console show the following message: 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:信息 - LogMediator 至: http ://www.w3.org/2005/08/addressing/anonymous,WSAction:,SOAPAction:,MessageID:urn:uuid:8073ca47-1ea3-4232-bcb7-4f947bca6591,方向:响应,消息= 执行默认的“故障”序列,ERROR_CODE = 0,ERROR_MESSAGE = 构建消息时出错,信封:

如果您在帖子正文中发送 json,则需要从客户端设置 Content-Type: application/json 标头。

添加以前的答案 -:对于GET请求,这工作正常。但是POST请求您需要为其余客户端指定 Content-Type:application/json 标头。

I Solved it : I edit the URI-Mapping tp "/" and edit the LOG mediators..我解决了它:我编辑了 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM