Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createService() Error #78

Closed
chris760 opened this issue Mar 13, 2015 · 7 comments
Closed

createService() Error #78

chris760 opened this issue Mar 13, 2015 · 7 comments

Comments

@chris760
Copy link

Hi Andrew,

I just found your MetadataServices class today (the one here https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls). I copied the class, test class, and examples class in to my salesforce developer org (along with all the other classes just to be on the safe side) and created a remote site setting for https://na16.salesforce.com (the URL of my dev org). When I try to run any of your examples however (like the customObject example), I get the following error, “Method does not exist or incorrect signature: createService()”.

What's weird is that I can't find the actual "createService()" method in the current MetadataServices class that you have posted on here (unless I'm totally missing something), so I think that might be what's causing the problem.

The code that I'm currently trying to execute in the salesforce developer console ExecuteAnonymous window is the following:

MetadataService.MetadataPort service = createService();
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Test__c';
customObject.label = 'Test';
customObject.pluralLabel = 'Tests';
customObject.nameField = new MetadataService.CustomField();
customObject.nameField.type_x = 'Text';
customObject.nameField.label = 'Test Record';
customObject.deploymentStatus = 'Deployed';
customObject.sharingModel = 'ReadWrite';
List<MetadataService.SaveResult> results = service.createMetadata( new MetadataService.Metadata[] { customObject }); handleSaveResults(results[0]);

Any ideas/suggestions would be much appreciated.

Thanks!

@chris760 chris760 changed the title createService() createService() Error Mar 13, 2015
@RandyTrigg
Copy link

Hi there,

I'm also using MetadataService for the first time (in a sandbox). I found definitions for createService and handleSaveResults in the examples class MetadataServiceExamples, so you can either copy them from there, or point to them if you've defined that class.

But now I get a timeout error from the WebServiceCallout.invoke method that is called whenever MetadataService computes results. Could you let me know if you've gotten past that?

Thanks,

  • Randy

@RandyTrigg
Copy link

Never mind. I now see how to increase timeout_x from the createService method. For details, see #77.

@afawcett
Copy link
Contributor

@chris760 When running code in annonymous mode, you need to full qualify the static methods you call by the class those methods belong in, in this case createService and handleXXXX methods reside in MetadataServiceExamples.cls. However the handleXXXX methods where private, so i've now updated them to public, so download a deploy a new MetadataServiceExamples class then the following will work...

    MetadataService.MetadataPort service = MetadataServiceExamples.createService();
    MetadataService.CustomObject customObject = new MetadataService.CustomObject();
    customObject.fullName = 'Test__c';
    customObject.label = 'Test';
    customObject.pluralLabel = 'Tests';
    customObject.nameField = new MetadataService.CustomField();
    customObject.nameField.type_x = 'Text';
    customObject.nameField.label = 'Test Record';
    customObject.deploymentStatus = 'Deployed';
    customObject.sharingModel = 'ReadWrite';
    List<MetadataService.SaveResult> results =      
        service.createMetadata(
            new MetadataService.Metadata[] { customObject });       
    MetadataServiceExamples.handleSaveResults(results[0]);

@rgupta124
Copy link

Hi Can some one help me test class for the MetadataServiceExamples .

@vivekgithub6
Copy link

Hi, Can any one help in writing the test class fro MetadataServiceExample class, I wrote but not getting full code coverage. A sample test class will help me out. Thanks in advance.

@afawcett
Copy link
Contributor

@vivekgithub6 test class is included in the repo here. 👍

@ankit15patel
Copy link

ankit15patel commented Dec 25, 2019

Hi,
I'm Trying To create a Remote Site By Metadata Service through Apex. But It gives an error of 'Unauthorized endpoint'. The Remote site will by my ORG Base URL.
Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants