Mule 4 - Create WSDL web service using Anypoint studio 7 - mule

I already read the documentation about the new way to create soap web service using newest mule (https://docs.mulesoft.com/apikit/4.x/apikit-4-soap-prerequisites-task), but it doesn't really help.
Because I try to do following, using that tutorial as example, when user enter the name, the size, the email and send the request in OrderTshirt function, my flow will call method in a java class, probably int OrderTShirt.order(String input) where input concat all the name, size, and email information, and return back the orderId, and submit back to the response to user. How I can approach this?
Here is the code that what I have right now, but I don't know how to use that datawave component really well, can someone give me an example for that?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit-soap="http://www.mulesoft.org/schema/mule/apikit-soap" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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 http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/apikit-soap http://www.mulesoft.org/schema/mule/apikit-soap/current/mule-apikit-soap.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<http:listener-config name="api-httpListenerConfig">
<http:listener-connection host="0.0.0.0" port="9999"/>
</http:listener-config>
<apikit-soap:config name="soapkit-config" port="TshirtServicePort" service="TshirtService" wsdlLocation="Tshirt2.wsdl"/>
<flow name="api-main">
<http:listener config-ref="api-httpListenerConfig" path="/TshirtService/TshirtServicePort">
<http:response>
<http:body>#[payload]</http:body>
<http:headers>#[attributes.protocolHeaders default {}]</http:headers>
</http:response>
<http:error-response>
<http:body>#[payload]</http:body>
<http:headers>#[attributes.protocolHeaders default {}]</http:headers>
</http:error-response>
</http:listener>
<apikit-soap:router config-ref="soapkit-config">
<apikit-soap:message>#[payload]</apikit-soap:message>
<apikit-soap:attributes>#[
%dw 2.0
output application/java
---
{
headers: attributes.headers,
method: attributes.method,
queryString: attributes.queryString
}]</apikit-soap:attributes>
</apikit-soap:router>
</flow>
<flow name="OrderTshirt:\soapkit-config" doc:id="969489c2-709c-43b7-915c-cc92d9f3c8c9">
<ee:transform doc:name="Transform Message" doc:id="5771f4b9-0060-4658-aa8a-fee10efc02c5" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
ns ns0 http://schemas.xmlsoap.org/soap/envelope
---
{
body:{
ns0#orderTshirtResponse:{
orderId:"10"
}
} write "application/xml"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="ListInventory:\soapkit-config">
<ee:transform doc:id="431ad9c7-f0bf-4b32-88bc-bbe8c6815317">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
body: {
soap#Fault: {
faultcode: "soap:Server",
faultstring: "Operation [ListInventory:\soapkit-config] not implemented"
}
} write "application/xml"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="TrackOrder:\soapkit-config">
<ee:transform doc:id="a09a0cc3-f28a-49aa-bb32-77368340a522">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
body: {
soap#Fault: {
faultcode: "soap:Server",
faultstring: "Operation [TrackOrder:\soapkit-config] not implemented"
}
} write "application/xml"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>

Related

Can't do validation because mule doesn't see payload

I'm trying to use validation connector to check value field for outcome "good" or "bad". Even if they are written in capital letters. The issue is when I use the validation connector to check payload.value it shows null. This is not the case when I debug on payload that shows the full payload. How can I solve it?
I have my xml code below:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:validation="http://www.mulesoft.org/schema/mule/validation" 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://www.mulesoft.org/schema/mule/validation http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
---
{Service: {
Id: "N2K99",
Value: "good"
}
}]]></dw:set-payload>
</dw:transform-message>
<validation:matches-regex value="#[payload.Service.Value]" regex="^(good|bad)" doc:name="Validate good or bad string"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
succes: hallo
}]]></dw:set-payload>
</dw:transform-message>
</flow>
</mule>
Error:
Message : Execution of the expression "payload.Service.Value" failed. (org.mule.api.expression.ExpressionRuntimeException).
Payload : <?xml version='1.0' encoding='UTF-8'?>
<Service>
<Id>N2K99</Id>
<Value>good</Value>
</Service>
Element : /testFlow/processors/1 # so-validate-regex
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:440)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:212)
at org.mule.mvel2.ast.ASTNode.optimize(ASTNode.java:160)
at org.mule.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:116)
at org.mule.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at org.mule.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
at org.mule.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
at org.mule.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113)
at org.mule.mvel2.MVEL.executeExpression(MVEL.java:953)
at org.mule.el.mvel.MVELExpressionExecutor.execute(MVELExpressionExecutor.java:87)
at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:228)
at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:163)
at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:142)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:217)
at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:188)
at org.mule.util.AttributeEvaluator.resolveValue(AttributeEvaluator.java:124)
at org.mule.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver$PassThroughEvaluatorDelegate.resolveValue(TypeSafeExpressionValueResolver.java:147)
at org.mule.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver$CaptureContextEvaluatorDelegate.resolveValue(TypeSafeExpressionValueResolver.java:137)
...
The problem that you are having is because the first DataWeave transformation -which I understand is used to mock the input- returns an XML string. This is Mule 3 so the validation uses a MEL expression to try to evaluate its input #[payload.Service.Value]. MEL doesn't know how to parse the XML so it fails with an error.
To resolve the issue you need only to transform the input into a Java object that MEL can evaluate. For example putting this transformation between the first Transform and the validate resolves the issue:
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload
]]>
</dw:set-payload>
</dw:transform-message>

why Multipart/form-data removing Nill in response Mule Dataweave

Please find my request having tag <Date xsi:nil="true"/> when it crosses the Multipart/form-data dataweave it is removing the xsi:nil="true part which is not expected in my scenario. I wanted that to be out as the same.
Also it is removing the namespace which is not the expected case. If i trying declaring ns xsi http://www.w3.org/2001/XMLSchema-instance in the first dataweave. In the response root element it is prefixing xsi:Locations.
Im struggling with this.
Wanted the response as mentioned below, whatever the input is same should come out without altering.
Using writeNilOnNull=true is putting nill on all the fields which i dont want either, wanted only for date.
Could anyone help on this. Thank you.
Input:
<Locations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Location>
<Id>2</Id>
<CarId>78</CarId>
<Packages>1</Packages>
<Date xsi:nil="true"/>
</Location>
</Locations>
Expected Response:
<Locations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Location>
<Id>2</Id>
<CarId>78</CarId>
<Packages/>
<Date xsi:nil="true"/>
</Location>
</Locations>
Flow:
<flow name="question" doc:id="8c836a85-9d0a-47a8-8e5a-f670b16f91eb" >
<http:listener doc:name="Listener" doc:id="52ffdb08-9587-4cb2-8232-9467e85ea0dc" config-ref="HTTP_Listener_config" path="/question"/>
<ee:transform doc:name="Transform Message" doc:id="da995adf-196b-4c7b-a265-874f059ed1bb" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<ee:transform doc:name="Transform Message" doc:id="75e5d876-855e-4d38-8468-3484c859f36e" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output multipart/form-data
---
{
"parts": {
"file": {
"headers": {
"Content-Disposition": {
"name": "file",
"filename": "",
"subtype": "form-data"
},
"Content-Type": "application/xml"
},
"content": payload
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
Add writeNilOnNull=true on your transformation. Like this
%dw 2.0
var x=read('<Locations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Location>
<Id>2</Id>
<CarId>78</CarId>
<Packages>1</Packages>
<Date xsi:nil="true"/>
</Location>
</Locations>','application/xml')
output application/xml writeNilOnNull=true
---
x

How to update the value of a Key in ObjectStore in Mule4?

My requirement is, i need to count messages which are processed for a day.
So, i created a subflow, where I created a persistent objectstore . I retrive it initially with the default value 0. Then , I pass that to java AtomicInteger class to do increment each time, when request comes in. Now I store the new value.
<sub-flow name="impl-message-counter:\counter-set-flow" doc:id="929c5fa5-74a2-4e8e-b1a0-43209b57222c" >
<os:retrieve doc:name="Retrieve" doc:id="565ecf6c-ffba-491e-b2c9-35ef4b4f52ad" key="counter" objectStore="Object_store" target="count">
<os:default-value ><![CDATA[0]]></os:default-value>
</os:retrieve>
<java:new constructor="AtomicInteger(int)" doc:name="New" doc:id="f0e75c0b-914a-44ee-9e24-a597025afd77" class="java.util.concurrent.atomic.AtomicInteger" target="atomicinteger">
<java:args ><![CDATA[#[output application/java
---
{
arg0 : vars.count as Number {class: "java.lang.Integer"}
}]]]></java:args>
</java:new>
<java:invoke doc:name="Invoke" doc:id="60779082-ad71-4770-b871-8d86044aa62a" instance="#[vars.atomicinteger]" class="java.util.concurrent.atomic.AtomicInteger" method="incrementAndGet()" target="newVal"/>
<os:store doc:name="Store" doc:id="8f85aa4f-5bce-4248-8a3b-a8cde27a1307" key="counter" objectStore="Object_store">
<os:value><![CDATA[#[vars.newVal]]]></os:value>
</os:store>
</sub-flow>
In the above flow, i want to add a check processor, to see the day is passed or not. If it passes midnight I wnat to reassign it to 0. Else continue with increment;
<choice doc:name="Choice" doc:id="120b1f05-7afe-4cfc-a103-0b26f9df7140" >
<when expression="#[now().hour==23 and now().minutes==59 and now().seconds==60]">
<os:store doc:name="Store" doc:id="3d995b22-a648-4c7f-af54-33d70b23705c" key="counter" objectStore="Object_store" >
<os:value ><![CDATA[#[0]]]></os:value>
</os:store>
</when>
<otherwise >
<os:store doc:name="Store" doc:id="8f85aa4f-5bce-4248-8a3b-a8cde27a1307" key="counter" objectStore="Object_store">
<os:value><![CDATA[#[vars.newVal]]]></os:value>
</os:store>
</otherwise>
</choice>
But above will work? I think it will skip if same key present in same objectstore? How can I update existing key?
This is good idea but you have to be aware that object store is unreliable. You can check it if you write a simple test and do load and stress test. Especially in cluster.
First and usually it works but later and especially on concurrent requests at the same moment it fails. So, use it if with caution and do not rely on it. Worst part - it will break you flow. What we can do is -
https://simpleflatservice.com/mule4/IgnoreUnreliableObjectStorage.html - wrapping every single call to object store to try block and simply ignore any failure or unexpected results.
Here is code
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:os="http://www.mulesoft.org/schema/mule/os"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 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
http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<flow name="selftestFlow" doc:id="79a89806-adea-4017-a838-8b8c3e2002df" >
<http:listener doc:name="Listener" doc:id="63128e3f-34f5-4f04-9b8a-0bebe67f763c" config-ref="HTTP_Listener_config" path="/counter"/>
<try doc:name="Try" doc:id="d5d83aa3-b271-41b0-98a6-381823164de4" >
<os:retrieve doc:name="Retrieve" doc:id="f6d3cccd-a7be-44fa-a51d-36bddbc5892f" key="test" target="localTest">
<os:default-value><![CDATA[N/A]]></os:default-value>
</os:retrieve>
<error-handler >
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="b14ab2e4-c871-4af8-a488-9c70284a525f" />
</error-handler>
</try>
<ee:transform doc:name="Transform Message" doc:id="bc50c855-34b4-4661-9f42-2b18e441782d" >
<ee:message >
</ee:message>
<ee:variables >
<ee:set-variable variableName="localTest" ><![CDATA[%dw 2.0
output application/java
---
if (vars.localTest is Number) ( vars.localTest as Number + 1 ) else ( 1 as Number )]]></ee:set-variable>
</ee:variables>
</ee:transform>
<try doc:name="Try" doc:id="2d54c616-7fb6-41ba-bc05-0918199bcba4" >
<os:store doc:name="Store" doc:id="2847d9db-d2f6-4bc4-a0a5-dca0eafbdd49" key="test">
<os:value><![CDATA[#[vars.localTest]]]></os:value>
</os:store>
<error-handler >
<on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="90e6616a-af11-4af6-a82f-e9823f764ceb" />
</error-handler>
</try>
<ee:transform doc:name="Transform Message" doc:id="bdc2a164-3d80-427f-b95d-a7dfc2b69400" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{ counter: vars.localTest }]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>

Pass http header value to the web service consumer

I am trying to pass the http header value as the web service consumer,
httpHeader
I use this property as web service input,
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 namespace
---
{
ns0#GetProject: {
ns0#projectId: inboundProperties."http.query.params".projectId,
ns0#upi: inboundProperties.sm_user
}
}]]></dw:set-payload>
</dw:transform-message>
I have also tried setting the sm_user to a variable and trying to access the variable in TransformMessage as below, but the same error,
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 namespace
---
{
ns0#GetProject: {
ns0#projectId: inboundProperties."http.query.params".projectId,
ns0#upi: flowVars.setUPI
}
}]]></dw:set-payload>
</dw:transform-message>
Error:
Server was unable to read request. ---> There is an error in XML document (3, 32). ---> Input string was not in a correct format.. Message payload is of type: ElementNSImpl
Transform XML using the SM_USER header:
<?xml version='1.0' encoding='windows-1252'?>
<ns0:GetProject xmlns:ns0="namespace">
<ns0:projectId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<ns0:upi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</ns0:GetProject>
Flow XML:
<flow name="ProjectEC">
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 namespace
---
{
ns0#GetProject: {
ns0#projectId: inboundProperties."http.query.params".projectId ,
ns0#upi: inboundProperties.SM_USER
}
}]]></dw:set-payload>
</dw:transform-message>
<ws:consumer config-ref="ECDataService_Consumer" operation="GetProject" doc:name="ECWebServiceConsumer"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<json:xml-to-json-transformer doc:name="XML to JSON"/>
<set-variable variableName="extractJsondata" value="#[json:GetProjectResponse/GetProjectResult]" mimeType="application/json" doc:name="Variable"/>
<set-payload value="#[flowVars.extractJsondata]" doc:name="Set Payload"/>
<json:xml-to-json-transformer doc:name="XML to JSON"/>
</flow>
Can someone tell me if I am missing something.
Thanks
Few checks
Check whether your xml is the exact format which your webservice is really looking for. or
Change the encoding from encoding='windows-1252' to UTF-8. Follow the url Output Encoding issue in mule esb. or
As trial and error version directly use the xml in postman to hit webservice ( without making dataweave to do the transformation). or
Make sure you have no space <?xml version='1.0' encoding="UTF-8"?> before starting of xml greater sysmbol tag.
Check the above 4 steps anyone of this might cause issue. Step 3 will be helpful for testing.

Mule DataWeave JSON content is null

Mule version: 3.7.3
Anypoint Studio: 5.4.0
To learn DataWeave, I've created a simple flow that executes twitter search, loops through each tweet, attempts to use DataWeave to condense the payload, then logs the results. The issue I'm running into is that the json seems to be null coming out of DW.
Tweet Text before DW:
Welcome to the world of #APILedConnectivity Lebron James! Your request has been processed by #MuleSoft #AnypointPlatform # 1986
The payload coming out of DW is not null:
org.mule.api.processor.LoggerMessageProcessor: DW Payload: com.mulesoft.weave.mule.WeaveMessageProcessor$WeaveOutputHandler#1657d772
However, the 'tweet' json element is null when outputting to logs:
org.mule.api.processor.LoggerMessageProcessor: Found Tweet: null
Here's my sample mule flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter" 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://www.mulesoft.org/schema/mule/twitter http://www.mulesoft.org/schema/mule/twitter/current/mule-twitter.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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<flow name="test-dataweaveFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/>
<twitter:search config-ref="TwitterConnection" query="#[json:hashtag]" doc:name="Twitter"/>
<foreach collection="#[payload.tweets]" doc:name="For Each">
<logger message="Payload before DW: #[payload.text]" level="INFO" doc:name="Logger"/>
<dw:transform-message metadata:id="99e88418-ce6a-4d18-a900-6c35d7f36c83" doc:name="Transform Message">
<dw:input-payload doc:sample="QueryResult.dwl"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
tweet: {
screenName: payload.user.screenName,
tweetId: payload.id,
tweetContent: payload.text
}
}
]]></dw:set-payload>
</dw:transform-message>
<logger message="DW Payload: #[payload]" level="INFO" doc:name="Logger"/>
<logger message="Found Tweet: #[payload.tweet]" level="INFO" doc:name="Logger"/>
</foreach>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
Screenshot of the mapping:
Any ideas where I might be messing things up?
Don't put the DataWeave transformer in the for each scope!
You can iterate in DataWeave, that will give you a better result probably.
You will create a map from the payload, the map operator accepts a collection.
The twitter connector will give you a collection of JSON objects.
The clue here is, drag the DataWeave transformer after the Twitter connector.
The input data in DataWeave will be provided and you will have autocomplete in you DataWeave script.
Docs: https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-reference-documentation
Some examples in how to map form JSON here:
https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-examples#json-to-xml