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
Related
In mule how can we serve endpoints for ../api/items and ../api/items/{itemId} at the same time ?
I was wondering how to make the ApiKit work for the endpoints.. I get nullpayload and an exeption when I call ../api/items which was exactly defined in https://support.mulesoft.com/s/article/ka434000000TPOz/Method-not-Allowed-on-API-Kit-requests
But there the solution mentioned is not practically applicable
In raml both of this endpoint are valid. You can use this there is no problem for that.
I resolved it just adding a groovy script before APIkit Router .
It is
import org.mule.api.transport.PropertyScope
if(message.getInboundProperty('http.request.path') == '/api/items')
message.setProperty('http.request.path', '/api/items/*', PropertyScope.INBOUND)`
And when I see a star * as the item id I behave accordingly in the flow implementation
I have a java component in Mule that is returning a String. When I print that string from within the java component, it reads as UTF-8 just fine in the console. However, when I return this as the payload, the subsequent logger and all downstream components can no longer read the UTF-8 characters. I've confirmed that my project's encoding setting is set to 'UTF-8'. I've also:
Setting MULE_ENCODING=UTF-8 before and after the Java component, both as an outbound property and invocation property.
Setting the encoding on the message in a mule expression, but that failed message.setEncoding('UTF-8') with an error stating it could not find the method setEncoding()
Using the following in the java component:
eventContext.getMessage().setPayload(myString);
eventContext.getMessage().setEncoding("UTF-8");
return eventContext.getMessage().getPayload();
Switching to a java transformer instead of a component, using the below config on the transformer, explicitly setting encoding to "UTF-8".
<custom-transformer encoding="UTF-8"
class="myDomain.myJavaTransformer" doc:name="Java"/>
I'm not sure what else to try to ensure the payload coming out of the java component/transformer is not interpreted or converted to another encoding...
The output should read: “Outstanding New Environmental Scientist”
The logger currently outputs is “Outstanding New Environmental Scientistâ€. I've corrected this in other parts of the flow by adding encoding=UTF-8 to any VM endpoints, for example. I've also confirmed that this can print correctly in a logger elsewhere in the flow.
There seems to be something happening after the String is returned from within the java class referenced by the java component and the subsequent mule logger...
try <object-to-string-transformer encoding="..." /> right after your java component
I had a problem with encoding too. It was not completely similar to your case but I took this action and it worked for me. (Byte to array using java serialization)
<set-property propertyName="MULE_ENCODING" value="UTF-8" doc:name="Property" />
<byte-array-to-string-transformer encoding="UTF-8" doc:name="Byte Array to String"/>
I used that when message is coming to my flow.
Also there is properties in wrapper and you can set that as well.
How are you reading the RSS feed? If it is using an endpoint, try setting the 'encoding' attribute for that endpoint?
Hi I am working with Mule Web Service Consumer and i was trying to call operation with Multiple Parameters it is warning me that
Warning : Operation Messages With More then 1 Part Are Not Supported
I just want to pass multiple parameters to access my SOAP method to achieve the task.
Is this the problem with Web Service Consumer or is their any way to deal with this.
I'm afraid this is a known limitation of the web services consumer. However you can accomplish this with the cxf component.
I having the same issue and found some information around it ...
There is a improvement logged in JIRA, may help if you vote for it :)
This link suggests that you can still use WSConsumer but need to do some hand crafting of the request XML ... I could not understand what that exactly it meant so if anyone has an example on it would be great
PS: The problem I had with using CXF component is that it does not play well with the new Dataweave transformer as the Dataweave needs to be placed within the response block and from there it cannot datasense the response coming out from the CXF component
The Solution here is very simple. You just have to comment other messages and then load metadata for non-commented message (for one which you're trying to load metadata). Repeat this procedure for all the other messages and you're good to go.
Hope this helps !
The Mule 'Using Transformers' documentation lists many out-of-the-box transformers, among them ObjectToInputStream and ObjectToString:
http://www.mulesoft.org/documentation/display/current/Using+Transformers
For ObjectToString, it can be configured for example like this:
<object-to-string-transformer name="object-to-string" />
but the corresponding does not work for ObjectToInputStream :
<object-to-input-stream-transformer name="object-to-input-stream" />
How can the ObjectToInputStream-transformer be configured, and what is it's default 'name'?
Thanks in advance!
Mule hasn't provided the config tag for this transformer.
But the transformer is already available in the mule basic transformers.
Try it this way.
<custom-transformer class="org.mule.transformer.simple.ObjectToInputStream"></custom-transformer>
Hope this helps.
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.