因此,使用 Mule ESB,我正在 Bing 中搜索某些 PDF 文件。然后我解析 JSON 响应以捕获文件位置的 URL。现在我需要检索文件并在本地保存。以下是我到目前为止所拥有的,但我有一种感觉,这一切都错了。如何完成用例?
我有两个问题:
1) 不知道如何从 #[message.payload.Url] 中删除“http”(因为 HTTP 端点将 http 添加到我传入的 url。
2)无法弄清楚如何检索文件。我什至不知道 HTTP Endpoint 是否是正确的选择。HTTP?文件?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:https="http://www.mulesoft.org/schema/mule/https" 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" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
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 ">
<flow name="BingFlow1" doc:name="BingFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<https:outbound-endpoint exchange-pattern="request-response" host="api.datamarket.azure.com" port="443" path="Data.ashx/Bing/Search/v1/Web?Query=%27contract%20california%27&WebFileType=%27PDF%27&$top=50&$format=Json" user="********" password="*****" doc:name="Bing"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<expression-transformer expression="#[message.payload.d.results]" doc:name="Expression"/>
<collection-splitter doc:name="Collection Splitter"/>
<http:outbound-endpoint exchange-pattern="request-response" host="#[message.payload.Url]" port="80" method="GET" doc:name="HTTP"/>
<file:outbound-endpoint path="/home/user/Documents/output" outputPattern="#[message.payload.ID].pdf" responseTimeout="10000" doc:name="File"/>
<echo-component doc:name="Echo"/>
</flow>
</mule>