I am trying to write ApexClass (soap tooling API) to a file, I want to load it later on the ApexClass.

I don’t know how to use the write function…

Wrote some trials such as:

javax.xml.namespace.QName qname = new javax.xml.namespace.QName("urn: tooling.soap.sforce.com", "ApexClass");
     File file = new File("c:/tooling.txt");

     OutputStream fop = new FileOutputStream(file);

     String content = "This is the text content:";

     com.sforce.ws.parser.XmlOutputStream xml = new XmlOutputStream(fop, false);
     com.sforce.ws.bind.TypeMapper mapper = new TypeMapper();        
     apexClass.write(qname, xml, mapper);


Any one knows how to use this function? Nothing is written to the file.


Just add flush to the XmlOutputStream at the end, and it works.

  • Would you mind putting your edit as an answer? That would make more sense, and you'd be able to accept your answer so that this question gets marked as resolved to other users. – Samuel De Rycke Dec 25 '13 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.