0

Edit: Rephrased entire question.

Hi,

I am writing a Java program to analyze some metadata on Salesforce and also modify some files.

I am trying to read a metadata file of type Profile into Profile object Salesforce provides: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm

I was able to do so by the following code: http://paste.ofcode.org/CRZMZsfcwdTmXz4zzCwJqY

When I want to modify the metadata. e.g. add Field Permission etc. and save it into an XML file back again. I am using this code: http://paste.ofcode.org/fZQZaGu3DMjfsHdndwq2WD

However, the output is different than what I downloaded from Salesforce.

Source from Salesforce: http://paste.ofcode.org/tq6S48VyHx7MJFtai5ZqUM

Output from my app: http://paste.ofcode.org/FnRSMfNrsM4CrEQ5e9Nc5Y

Please assist :) Thanks !

1
  • @sfdcfox Could you please help? :)
    – sfdcdev
    Commented Nov 28, 2016 at 16:34

1 Answer 1

0

It's been a while since I wrote any Java code, but I think the XML output is appending a default namespace, I cribbed this form stackexchange.com which may be of use:

String nsURI = "http://soap.sforce.com/2006/04/metadata";
XMLOutputFactory outF = XMLOutputFactory.newFactory();
outF.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
XMLStreamWriter out = outF.createXMLStreamWriter(System.out);
out.setDefaultNamespace(nsURI);
1
  • Hi, thanks for your help. The write method on the profile object expects an XmlOutputStream. I get a compilation error when I provide something else. I am using the XmlOutputStram from the WSC
    – sfdcdev
    Commented Nov 30, 2016 at 7:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .