You need to sign in to do that
Don't have an account?

listMetadata 101?
I'm working on a simple proof which uses the Metadata API. As I understand it you login to the standard data API and set the Metadata svc session values then you can make calls. Here's a sample of that (I have another wrapped assembly that handles all data calls).
internal MetaWrapper() { _svc = new sforce_meta.MetadataService(); _wrapper = new MetadataWrapper(); Main.sforce.LoginResult _lr = _wrapper.Login(); _svc.SessionHeaderValue = new sforce_meta.SessionHeader {sessionId = _lr.sessionId}; _svc.Url = _lr.serverUrl; }
That's all fine and dandy and I can see in my watch that I have a session URL and Id set. URL in this instance is :
Url "https://cs3-api.salesforce.com/services/Soap/u/18.0/00DQ0000000Ahhk"
Now at this point I'm just trying to do a simple query on all custom objects to test the connectivity and whatnot.
sforce_meta.ListMetadataQuery query = new sforce_meta.ListMetadataQuery {folder = null, type = "CustomObject"};
sforce_meta.FileProperties[] prop = _svc.listMetadata(new sforce_meta.ListMetadataQuery[] {query}, 20);
Here's the error I always get:
[System.Web.Services.Protocols.SoapHeaderException] {"No operation available for request {http://soap.sforce.com/2006/04/metadata}listMetadata"}
Am I missing something simple? Do I need to do something different withthe URL returned from the data svc binding? I've tried using various other API versions as the second arg in the listMetadata() method, with the same results.
Any direction at all would be helpful.
-Bryan
Here's a sample of getting the workflow file for the workflows on contact, basically it defines a package that contains workflow for contacts, and then fetches it, and writes it out to a zip file. There's no way currently to read the workflow directly in the response.
All Answers
You need to use the metadataServerUrl (or something similar) not serverUrl.
Right on, I totally missed that one. Cheers!
Ok, so Simon yolu solved that problem and now I'm looking at what to do next. I mean I can call listMetadata and give it "Workflows" and it returns the list. Fine.
What I'm looking to do it to "query" for a workflow to eventually get at the rules/criterias for that workflow. For now I'll take being able to pull back a populated Workflow[] collection to then figure out what to do it. But to get that collection I don't understand if I'm to use retrieve with a manifest file every time (I'm basing this off of the insane Java snippet in the API doc) or if it's anything close to being more intiutive than that.
Like:
RetrieveRequest retrieveRequest = new RetrieveRequest();
retrieveRequest.setApiVersion(18.0);
retrieveRequest.MAGICALLYISSETTOGIVEMEWORKFLOWS = Please;
RetrieveResult _result = _metaSVC.Retrieve(retrieveRequest);
I'm probably not making much sense, but honestly this API has me grasping at straws. I don't want to iterate through a list of names to just print them, I want to get to Workflows, interate through them and acess the properties that I can see in the API doc.
Any help would be GREATLY appreciated.
- Bryan
Here's a sample of getting the workflow file for the workflows on contact, basically it defines a package that contains workflow for contacts, and then fetches it, and writes it out to a zip file. There's no way currently to read the workflow directly in the response.
Thanks for that snippet. So far was able to pull down the workflows via the API and then I got a zip file. Opening that gave me what I needed there, now i'm writing the XML code that traverses the XML doc for a given workflow rule name and puts its contents into an object for use. Any iade at all why this API is file based? I get that it's handy at time (like with Eclipse) but other than that it really makes any work with it more than a beast.
FWIW this is what I'm working with on geting the values out of the certain rule:
After this works my plan is to get the pdf pull retrival into some type of stream that I can read the workflows out of using something like the DotNetZip library.
Simon, thanks for your help on this.
Right, for the sake of closure, below is a small console app I created that uses the DotNetZip lib along with our inhouse sforce DAL to retrieve workflow rules on an object, and then look for one specific workflow rule (setting a coupe of fields for testing). This gets the zip from the RetrieveRequest and, in stream, converts it to an XDocument for Linq to XML...and all of that. As is..
I hope this helps anyone out, and thanks for the pointers Simon.
Cheers.
- Bryan
For what it's worth - the file-based nature of the metadata API can be a bit annoying when you only have to work with a single type of metadata (in your case, workflow). But most people actually need to deal with multiple types of metadata, and some metadata isn't particularly suited to representation in XML (i.e. the body of an apex class).