how to create an output file based on xml data in mule - mule

Im very new to mule so hopefully someone out there can help me out. Im trying to create an output based on a content in my xml
Ex
<Header>
<UniqueID>AAA_12345</UniqueID>
</Header>
Id like the filename to be the the UniqueID ie AAA_1245.xml
I found a few syntax on the net but it doesnt work for me. My syntax is
<file:outbound-endpoint path="${cwMessagesPath}/out" outputPattern="#[xpath:/Header/UniqueID].xml" connector-ref="cwksbDefaultFileConnector" />
for some reason, mule creates #[xpath: as a directory, Header as another directory and then the filename as UniqueID].xml
Im using mule 2.2.1
Thanks for your help.

This should work.
Is cwksbDefaultFileConnector configured in any specific manner?
Also, I think in Mule 2 it was possible to configure other placeholders than #[ ] for expressions. Are expressions working with this syntax elsewhere in your application? If yes, then the problem is different.
Do you run standalone or embedded? If embedded, make sure you have the mule-module-xml dependency in your project's POM.
Finally, what is the payload type of the message that hits the file:outbound-endpoint? Maybe some manual transformation is needed in Mule 2 before using XPath.

Related

Unable to reference a sub-flow present in another file mule 4

I am trying to reference a flow/sub-flow from one file to another in mule 4 but keep getting the error "flow-ref at test.xml:76 is pointing to genericFlow which does not exist"...during deployment.... even though the anypoint studio is able to find it...
Edit:
I have been able to solve this problem.
I found that the flow I was referring had a problem due to which it was not getting initiated or something....The problem was that I was using && instead of "and" as relative operator....after fixing that it worked fine....
The flow ref name shouldn't include the name of the file, once the file is included into the mule-artifact.json in the "configs" array property. You should reference the sub-flow by doing <flow-ref name="{nameofthesubflowontheotherfile}">
Take in mind that you cannot have flows or subflows with the same name

Could not initialise JsonSchemaValidator

I am using Json schema Validator in mule flow. There are many flows in one project which are using same json schema validator.
Whenever I tried to run the project, which is imported from SVN, it gives an error as Could not initialise JsonSchemaValidator.
I could not find the reason for it. ow should I resolve this?
Thanks in advance.

Mule APIKit and multiple RAMLs

It is possible using multiple RAML files in one APIKit Mule Project?
Let's say I have two functions /api/func1 and /api/func2.
Each of the functions is defined in its own raml - func1.raml and func2.raml.
I've generated a flow in Anypoint for the first function using the APIKit wizard. It's working ok.
Now, I'm trying generating a flow for the second function. The flow is generated with no errors. However, it just doesn't work. I've tried fixing the URLs, bindings, configurations and nothing really helps.
Note, that I don't wanna bind both the RAMLs into one file. The reason is that it's easier to develop/maintain the functions separately.
The only solution I can see is to define two separate projects. But this is not really what I'd like to do.
So, looking for an advice of how to deal with this situation.
Thanks,
Ok, actually, it's possible.
What you need to do is make the "Path"es different in the HTTP connectors for the flows generated.
The apikit wizard generates the default path that looks like this: "/api/*".
So, Mule generates an error when attempting to deploy the app. What you need to do is changing paths to "/api/func1/" and "/api/func2/"
You can continue having a single RAML file and make external references to simplify your raml, here is an example:
#%RAML 0.8
title: Eventlog API
version: 1.0
baseUri: http://eventlog.example.org/{version}
schemas:
- eventJson: !include eventSchema.json
eventListJson: !include eventlistSchema.json
Also going by strict REST design it is recommended to have a resource related details maintained in a single RAML file.
Optionally you may edit the url's to resolve any context related conflict.

How can i use the Mule Studio data mapper for producing output generated from a complex XSD schema ?

I want to post a message to a SOAP webservice with MULE Enterprise edition.
For creating the Request object i am using a data mapper with the
input a POJO and for
the output i selected XML , and from example XML schema i added my own XSD.
Because there are a lot of elements in the xsd, i selected the root element from the list provided.
Then i am dragging the fields from input to the corresponding values i want in the output.
(i also tried to map just one field, to be sure that i keep the minimum the probability for error).
And now the problem:
when the flow is accessed, the following WARN is shown and the data-mapper fails
*[XML WRITER:EXT_XML_WRITER0] - Invalid mapping (With port binded to root element, result might contain multiple root elements. Such XML is not well-formed. To avoid that, set 'Records per file' or 'Max number of records' component attribute to '1'.)*
Where can i set this kind of options in the data mapper ?
And also i want the root element to be only one, i don't need a foreach for the root element, i just need to fill the contents of it. Can i specify this anywhere in the data mapper ?
Thanks.
Mule EE DataMapper uses CloverETL for data transformations, and this annoying warning concerns CloverETL settings. I don't know if you can advise CloverETL to use a specific configuration file in the context of Mule DataMapper, but you can always edit the mapping file generated by Mule with a text editor. Just find your root Node entry in the mapping file and add recordsPerFile="1" attribute.
The problem with this is that Mule may overwrite your manual edits if you use the graphical editor, though.
Check out the Anypoint Studio May 2014. Mule now includes a new Web Service Connector for posting messages to a SOAP web service using just a WSDL. Studio will read the XML Schema from the WSDL and automatically create the metadata for DataMapper for you. See http://www.mulesoft.org/documentation/display/current/Web+Service+Consumer for more details.

How can i setpayload on xml config?

i want to set some message to payload.
i always used filter to set some data to payload.
i think they are some ways to setpayload whith out using filter.
could somebody help me how to setpayload on the mule-config.xml file ?
i tried
<set-payload value="something"/>
but doesn't works .. i am using mule 3.2
thanks!
The set-payload transformer is available starting with Mule 3.3.
For 3.2, the shortest is expression-transformer:
http://www.mulesoft.org/documentation-3.2/display/32X/Expression+Transformer+Reference