Search code examples
javaweb-servicesjava-metro-framework

Metro stack java web services write own serializer/deserializer


I am facing some problem while returning data from web services.
I am using Metro stack.

Problem:
The problem is my data contain some control characters. I don't want to encrypt my data, as this will involve client side code changes as well.
Better way is to remove control characters, but character by characters scanning and removing/replaceAll will have some performance impact.

Probable solution:
What I want to do is intercept SOAP message before metro send it to client and check control characters. And then replace all control characters of XML before returning.

Do anyone here have any idea how can I intercept response before returning? Or
how I can write my own serializer/deserializer where I can replace control char?

Thanks.


Solution

  • I found XMLAdapter very useful in my case. Adding info as in case any buddy can find it useful.
    Reference: http://weblogs.java.net/blog/kohsuke/archive/2005/09/using_jaxb_20s.html

    XMLAdapter contain abstract method marshal and unmarshal. So I used appropriate encoder in marshal/unmarshal method.