I'm setting header using xpath() expression. However, xpath() return NodeSet. In my case xpath("//base/#href") return string. I'd like to convert the result of xpath to string. How could I do it with Camel DSL?
You can use the DSL like this, setting the resultType with String.class
xpath(String text, Class<?> resultType)
Seems that did the trick
xpath("//base/#href", String.class)
Related
I have a problem reading different fileName from Camel file component.
from("file:/in?fileName={{property.name}}")
.to(file:/out)
I used fileName={{property.name}} from application.yml, but I need to use it from String.
Is there any way to use it like:
String name = "blabla.xml";
from("file:/in?fileName=${name}")
.to(file:/out)
Camel don't support it. String concatenation can solve your problem:
from("file:/in?fileName="+name)
or you can set a property and then read it:
String name="name";
from("direct:start")
.setProperty("name",constant(name))
.to("file:/in?fileName=${exchangeProperty.name}");
How do we decode $content?
My content:
When I simply do this:
I get this:
I've also tried this:
body('Get_blob_content')['$content']
that didn't work either:
another attempt:
base64ToString(body('Get_blob_content')['$content']):
How do we decode $content?
I agree with George Chen, the solution is decodeBase64(body('Get_blob_content')), but you check if the content is a valid json in String format, if not, try to add string function:
decodeBase64(string(body('Get_blob_content'))).
Regards.
Is it possible to get URL fragment parameters in C under glib ?
I've got a url like file://localhost/home/me/notepad.txt#line=100,2
What's the best way to get the parameters specified at the end of the url ?
There’s no single GLib function which will do what you want. If you can use libsoup (also part of the GNOME stack), then you can do it using SoupURI:
g_autoptr(SoupURI) uri = soup_uri_new (uri_string);
const gchar *fragment = soup_uri_get_fragment (uri);
That will set fragment to line=100,2. You’ll have to do further parsing of whatever your fragment format is, by hand. g_strsplit() would be useful for that.
You may also take a look on the function parse_sftp_uri from gnome-terminal terminal-nautilus.c file.
It can be easily adapted for general URIs.
Unsure if you mean to parse notepad.txt#line=100,2 or #line=100,2, nevertheless my answer should work in both cases.
You can use the strrchr() (man strrchr) function to get the last occurence of a character within a string.
Something like:
char *file;
file = strrchr(url, '/') + 1;
I have to create XML from Java objects and I use the Simple framework.
My problem is I need to send some names in camel case:
#Element
String ChannelData
and the xml element produced is:
<channel-data>
Which is rejected by the receiver, it needs to be
<channelData>
I cannot find a way to configure this, I tried adding the name explicitly:
#Elenemt(name="channelData")
but without success.
Ok I solved it.
I actuallt initialized the Persister with the wrong format:
Format format = new Format(0, null, new HyphenStyle(), Verbosity.HIGH);
Instead of:
Format format = new Format(0, null, new CamelCaseStyle(), Verbosity.HIGH);
Why are we not able to use getOut : Message-Exchange here down in this code to change file name by using camel apache:
String origFileName = (String) exchange.getIn().getHeader(exchange.FILE_NAME_CONSUMED);
System.out.println(origFileName);
exchange.getIn().removeHeader(Exchange.OVERRULE_FILE_NAME);
exchange.getIn().setHeader(Exchange.FILE_NAME,"newFileName.xml");
See this FAQ which explains about IN vs OUT and what you should favor use
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html