Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MuleSoft Criando fluxo preconfigurado

MuleSoft Criando fluxo preconfigurado

MuleSoft Criando fluxo preconfigurado

Alex teles

August 09, 2016
Tweet

More Decks by Alex teles

Other Decks in Education

Transcript

  1. <!– XML Gerado --> <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"

    xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jetty="http://www.mulesoft.org/schema/mule/jetty" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule- tracking-ee.xsd http://www.mulesoft.org/schema/mule/jetty http://www.mulesoft.org/schema/mule/jetty/current/mule-jetty.xsd http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
  2. <sfdc:config doc:name="Salesforce" name="Salesforce" password="${sfdc.password}" securityToken="${sfdc.securityToken}" username="${sfdc.username}"/> <http:listener-config doc:name="HTTP Listener Configuration"

    host="0.0.0.0" name="HTTP_Listener_Configuration" port="8081"/> <flow name="showFormFlow"> <http:listener allowedMethods="GET" config-ref="HTTP_Listener_Configuration" doc:name="HTTP" path="/"/> <sfdc:describe-global config-ref="Salesforce" doc:name="Salesforce"/> <dw:transform-message doc:name="Tranform to HTML set of option values" metadata:id="8eb02dfc-9b91-4a58-bf41- 9cbbc6e1545a"> <dw:input-payload doc:sample="DescribeGlobalResult.dwl"/> <dw:set-payload><![CDATA[%dw 1.0 %output application/xml --- div: { (payload.sobjects map { option @(value: $.name): $.label }) }]]></dw:set-payload> </dw:transform-message>
  3. <object-to-string-transformer doc:name="Object to String" mimeType="text/html"/> <parse-template doc:name="Parse Template" location="./src/main/resources/retrieval/index.html"/> </flow>

    <flow name="salesforceDataRetrievalFlow"> <http:listener allowedMethods="POST" config-ref="HTTP_Listener_Configuration" doc:name="HTTP" path="/"/> <sfdc:query-all config-ref="Salesforce" doc:name="Salesforce" query="#[&quot;SELECT id, name &quot; + (payload.field.isEmpty() ? &quot;&quot; : &quot;,&quot; + payload.field) +&quot; from &quot; + payload.object +&quot; where &quot; + payload.searchKey + &quot; like '%&quot; + payload.searchValue +&quot;%'&quot;]"/> <set-variable doc:name="Set blank response" value="#[[]]" variableName="response"/> <foreach doc:name="For Each"> <byte-array-to-string-transformer doc:name="Byte Array to String"/> <set-variable doc:name="Set response variable" value="#[flowVars.response + payload]" variableName="response"/> </foreach> <set-payload doc:name="Set response" value="#[response]"/> <byte-array-to-string-transformer doc:name="Byte Array to String"/> <logger doc:name="Log results" level="INFO" message="Result: #[payload]"/> <catch-exception-strategy doc:name="Catch Exception Strategy"> <set-payload doc:name="Set Payload" value="Invalid Salesforce query."/>