0
我在mule项目中创建了一个简单的Restful web服务。 REST风格的WS的Mule:HTTP请求出站端点无法发送请求到RESTFul Web服务(HTTP侦听器)
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="[{"ID":1, "code": "ER38sd","price": 400, "departureDate": "2016/03/20", "origin": "MUA", "destination": "SFO", "emptySeats": 0, "plane": {"type": "Boeing 737", "totalSeats": 150}}, {"ID":2,"code": "ER45if", "price": 345.99, "departureDate": "2016/02/11", "origin": "MUA", "destination": "LAX", "emptySeats": 52, "plane": {"type": "Boeing 777", "totalSeats": 300}}]" mimeType="application/json" doc:name="Set Payload"/>
</flow>
</mule>
而且在同一个项目中,我创建了一个另一个Web服务仅仅是调用REST风格的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>
在这里首先我检查与默认响应时间的代码,但是会出现一个错误,如“错误发送HTTP请求 ”。后来我将默认响应时间30秒更改为300秒,但仍然出现相同的错误。 有人可以告诉我这个问题如何解决?我经历了许多类似的帖子,但是在所有帖子中,他们都告诉要增加响应时间并进行检查。但增加响应时间也无法帮助我摆脱这个问题。
编辑: -我也设置代理到我的Anypoint Studio。