Question: I need help with this question. 

I'm using the [camel-http](http://camel.apache.org/http.html) component as shown [here](https://stackoverflow.com/questions/4353700/http-post-from-activemq-using-camel/4354877#4354877) but I'm having trouble because the body I'm sending has unescaped ampersands. This is causing the query string on the receiving server to break the post into multiple post parameters. 

I know I could create compiled routes in java, but I must use the spring xml dialect so that new routes may be create/changed in the config files without a recompile.

So, in short, I'd like to URL Encode the ${body} property on my route using the spring dialect as shown in the (obviously invalid) pseudocode below.

```
<setBody inheritErrorHandler="true" id="setBody2">
    <simple>name=<urlencode>${body}</urlencode></simple>
</setBody>

```

Answer: 
Ok, I bit the bullet. I created a java POJO

```
package com.wufoo.camel;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.apache.log4j.Logger;

public class PayloadEncoder {
    public String getEncodedBody(String body) throws UnsupportedEncodingException {
        Logger mylogger = Logger.getLogger("log4j.logger.org.apache.camel");
        mylogger.info("Appending payload and URL Encoding");
        String encodedBody = new StringBuffer()
            .append("payload=")
            .append(URLEncoder.encode(body, "UTF-8")).toString();
        return encodedBody;
    }
}

```

Then injected it into the context

```
<bean id="payloadEncoder" class="com.wufoo.camel.PayloadEncoder" />

```

And finally used a transform to encode the body

```
<transform>
    <method bean="payloadEncoder" method="getEncodedBody"/>
</transform>

```

That works. If anyone can tell me what's wrong with this approach, please let me know.
You can also use groovy language, like this:

```
<?xml version="1.0" encoding="UTF-8"?>
    <blueprint
    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.osgi.org/xmlns/blueprint/v1.0.0
    http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="file:camel/input"/>
            <log message="Moving ${file:name} to the output directory"/>
            <setBody>
                <groovy>
                    "name=" + URLEncoder.encode(request.getBody(String.class));
                </groovy>   
            </setBody>
            <to uri="file:camel/output"/>
        </route>
    </camelContext>
</blueprint>

```