+ Start a Discussion

Import Metadata WSDL into Apex?

Has anyone had success in calling Salesforce metadata API functions from Apex code? We tried just simply importing the metadata WSDL using the auto-import functionality, but there was a namespace conflict.

Is this possible? Any suggestions would be most apprecaited. Right now, we're looking at putting java code on a separate webserver to programatically update the metadata of a number of orgs. We'd really like to package some code up that would update it from within the app.

I have tried to do this myself. After some manual editing of the WSDL, I was able to generate the Apex through WSDL2Apex. The
code was too long so I had to break it out into 2 Apex Classes. But I got that far. One issue I ran into was the lack of support for
attributes within WSDL2Apex generated code (which the metadata api requires for some functionality).

I believe WSDL2Apex is being enhanced to support attributes in Spring '09 (upcoming release) and at that point, I hope to revisit this possibility.

That's good to hear. We are looking to update page layouts specifically. Do you recall which functionality worked/broke because of the attributes support?
This thread should help future readers: https://developer.salesforce.com/forums/ForumsMain?id=906F00000008mX4IAI