Converting Java object to XML


We use webMethods glue to invoke some webservices. Some of the Java classes are generated by wsdl2java tool. After wm makes the webservices call, we want to serialize the return Java Object to a XML string and write it to a file. Is there any way to do that for us in webMethods? We have schema defined.