Reputation: 1655
I have a sample java input into the Dataweave that I copied from the debugger in Anypoint Studio which looks like this:
result=[{Office=NYC, Dept=Sales, EmployeeCount=1000}]
I want to use it as sample data for the input in dataweave and copied it into the edit sample data section and nothing happens in the preview window even though the dataweave code is just:
%dw 1.0
%output application/json
---
payload
How can I use the java above with the preview mode in transform message?
I am using Anypoint Studio 6.2 and Mule 3.8.3.
Thanks
Upvotes: 1
Views: 906
Reputation: 2832
Please check if you giving sample data in a right way using dwl.
Try below flow to build your contruct,this works perfectly fine and generates a preview with sample data,check images below -
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8082" basePath="/testapi" doc:name="HTTP Listener Configuration"/>
<flow name="uri">
<http:listener path="uri/{param}/resource" config-ref="HTTP_Listener_Configuration" doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message" >
<dw:input-payload doc:sample="sample_data\string.dwl" mimeType="application/java"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload]]></dw:set-payload>
</dw:transform-message>
</flow>
Custom Java object used in this case looks like : MyTest.java
public class MyTest {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
int age;
@Override
public String toString() {
return "MyTest [name=" + name + ", age=" + age + "]";
}
}
Input payload mapping(Context)
Upvotes: 0