Using Broker Client API

I have currently a Java client subscribing to documents(XML) published to the broker from IS. When the subscribing service receives the documents, The documents are in a ‘C’ style structure. Is there any way I can convert the C style record structures to XML documents. I tried using a flow documentToXMLString from my java client. But I am getting a ClassCastException. I will appreciate if you can help me on this.