Not sure how you are accessing/invoking a web service. If you have a SEI like the following, you donot have to do any escaping. JAX-WS runtime will do that for you.
String echo(String name) {
return "hello#hello";
}
[Message sent by forum member 'jitu' (jitu)]
http://forums.java.net/jive/thread.jspa?messageID=205932