Niuf

MuleSoft Configuration - Query & URI Params

Nov 3rd, 2025
1,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.61 KB | Source Code | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mule
  3.     xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
  4.     xmlns:http="http://www.mulesoft.org/schema/mule/http"
  5.     xmlns="http://www.mulesoft.org/schema/mule/core"
  6.     xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
  7.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
  8. http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
  9. http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
  10.     <http:listener-config name="HTTP_Listener_config_test" doc:name="HTTP Listener config" doc:id="1909e2a5-79c7-4206-aa2e-b8df68f5e133" >
  11.         <http:listener-connection host="0.0.0.0" port="8090" />
  12.     </http:listener-config>
  13.     <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="17198395-4ca4-4b2c-b474-5a842d68a1e6" >
  14.         <http:listener-connection host="0.0.0.0" port="8081" />
  15.     </http:listener-config>
  16.     <http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="54a87666-ec11-4714-b2d4-1f2a1d403b14" >
  17.         <http:request-connection host="jsonplaceholder.typicode.com" />
  18.     </http:request-config>
  19.     <flow name="External-GETFlow" doc:id="7f5a5c71-3a7f-46aa-b436-9bb37d7254be" >
  20.         <http:listener doc:name="Listener" doc:id="9167eb7d-ed87-475f-b733-764a21576fa8" config-ref="HTTP_Listener_config" path="/todo/{id}" allowedMethods="GET"/>
  21.         <http:request doc:name="Request" doc:id="0abe5435-8d6b-4eb2-9c15-0977f2e730af" config-ref="HTTP_Request_configuration" url="https://jsonplaceholder.typicode.com/todos/#[attributes.uriParams.id]" outputMimeType="application/json" method="GET"/>
  22.         <logger level="INFO" doc:name="Logger uriParams" doc:id="21397b93-aa9d-4f7f-a1ee-7dfb8627ebb6" message="#[attributes.uriParams]"/>
  23.         <logger level="INFO" doc:name="Logger QueryParams" doc:id="097ab03a-d084-4b67-9c02-f53ebea33fdc" message="#[attributes.queryParams]"/>
  24.         <ee:transform doc:name="Transform Message" doc:id="8a332f75-9f5e-4c08-abb8-9169a07d32f7">
  25.             <ee:message>
  26.                 <ee:set-payload>
  27.                     <![CDATA[%dw 2.0
  28. output application/json
  29. var id = (attributes.uriParams.id default 0) as Number
  30. var todo = (payload filter (item) -> item.id == id)[0] default {}
  31. ---
  32. {
  33.  "questo รจ il mio uri": id,
  34.  "questo รจ il mio query": attributes.queryParams.completed,
  35.  "idAPI": todo.id,
  36.  "titleAPI": todo.title,
  37.  "completedAPI": todo.completed
  38. }
  39. ]]>
  40.                 </ee:set-payload>
  41.             </ee:message>
  42.         </ee:transform>
  43.     </flow>
  44. </mule>
  45.  
Advertisement
Add Comment
Please, Sign In to add comment