Mule:HTTP请求出站端点无法向RESTFul Web服务(HTTP侦听器)

时间:2017-02-17 05:06:46

标签: rest http mule httpresponse anypoint-studio

我在一个mule项目中创建了一个简单的Restful Web服务。

Restful WS的XML配置文件: -

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <http:listener-config name="American_HTTP_Listener_Configuration" host="0.0.0.0" port="8181" doc:name="HTTP Listener Configuration"/>
    <flow name="americanFlow">
        <http:listener config-ref="American_HTTP_Listener_Configuration" path="/api/flights" doc:name="HTTP" allowedMethods="GET"/>
        <set-payload value="[{&quot;ID&quot;:1, &quot;code&quot;: &quot;ER38sd&quot;,&quot;price&quot;: 400, &quot;departureDate&quot;: &quot;2016/03/20&quot;, &quot;origin&quot;: &quot;MUA&quot;, &quot;destination&quot;: &quot;SFO&quot;, &quot;emptySeats&quot;: 0, &quot;plane&quot;: {&quot;type&quot;: &quot;Boeing 737&quot;, &quot;totalSeats&quot;: 150}}, {&quot;ID&quot;:2,&quot;code&quot;: &quot;ER45if&quot;, &quot;price&quot;: 345.99, &quot;departureDate&quot;: &quot;2016/02/11&quot;, &quot;origin&quot;: &quot;MUA&quot;, &quot;destination&quot;: &quot;LAX&quot;, &quot;emptySeats&quot;: 52, &quot;plane&quot;: {&quot;type&quot;: &quot;Boeing 777&quot;, &quot;totalSeats&quot;: 300}}]" mimeType="application/json" doc:name="Set Payload"/>
    </flow>
</mule>

在同一个项目中,我创建了另一个Web服务,只是为了调用上面的Restful WS。

以下是用于调用WS的XML配置文件: -

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:context="http://www.springframework.org/schema/context" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <context:property-placeholder location="flights-${env}.properties"/>
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <http:request-config name="American_HTTP_Request_Configuration" protocol="HTTPS" host="localhost" port="8181" responseTimeout="300000" doc:name="HTTP Request Configuration"/>
    <flow name="implemantationFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/american" allowedMethods="GET" doc:name="HTTP"/>
        <flow-ref name="setAirportCodeSubFlow" doc:name="setAirportCodeSubFlow"/>
        <http:request config-ref="American_HTTP_Request_Configuration" path="/api/flights" method="GET" doc:name="American REST Request"/>
        <logger level="INFO" doc:name="Logger"/>
    </flow>
</mule>

此处首先,我使用默认响应时间检查代码,但发生错误,例如&#34; 发送HTTP请求时出错 &#34;。后来我将默认响应时间30s更改为300s仍然会出现相同的错误。 谁能告诉我这个问题是如何解决的?我已经经历了很多类似的帖子,但在所有这些帖子中,他们都在告诉我们增加响应时间和检查。但是增加响应时间也无法帮助我摆脱这个问题。

编辑: - 我还将代理设置为Anypoint Studio。

1 个答案:

答案 0 :(得分:0)

在您的请求中,配置<%= f.simple_fields_for :ethics do |ff| %> <%= ff.error_notification %> <% @proposal.ethics.errors.full_messages.each do |msg| %> <%= li= msg %> <% end %> <%= render 'package/ethics/ethics_fields', f: f %> <% end %> 代替protocol="HTTP"

HTTPS