function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex 2.0Alex 2.0 

metadata API examples

Hi All,
 
are there any examples of using the Metadata API with PHP? I need to create some objects with many fields, doing it programmatically would save me loads of time.
 
Also, why the metadata API is available for download in my developer edition and not in the sandbox or production environment?
 
 
Thanks,
 
Alex
msimondsmsimonds
We're all still waiting for Nick to release the new version of the PHPToolkit, until that happens, it is not supported
Alex 2.0Alex 2.0
Thanks for you reply!

Roughly how long do you think that will take? (as in days, weeks or months?)


It should be possible to use the metadata calls now with just the PHP SOAP library, after all that's what Nick uses to build the toolkit right? I think I just have a problem constructing the headers

Code:
//partner client

$wsdl = "/path/to/partner.wsdl.xml";
$sfdc= new SforcePartnerClient();
$sfdc->createConnection($wsdl);
$sfdc->login($username, $password);

//metadata client
$wsdl = "/path/to/metadata.wsdl.xml";
//pass the partner client header
$sforce_header = new SoapHeader('urn:metadata.soap.sforce.com', 'SessionHeader', array('sessionId' => $sfdc->getSessionId()));
//create th header
$client = new SoapClient($wsdl);
$client ->__setSoapHeaders(array($sforce_header));
//pass a new object that we want to create
$object=new sObject();
$object->fields=array('fullName' => 'testobj');

try{
 $client->create($object);
}
catch (Exception $e) {
    echo $e -> getMessage ();
}

 
with this code I get :

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session


I thought I would have to use the same session with the metadata calls bue either that's not true, or I'm passing the session wrong.

Any ideas?

Thanks again for your help.

--Alex
msimondsmsimonds
Alex

Have you made any headway on this? 

Have you been able to create any custom objects using the metadata wsdl

~Mike
Alex 2.0Alex 2.0
Mike,

I have not looked at this any further, I guess I was hoping that the tookit would come out soon.

If there are examples in other languages, I can try and emulate the functionality in PHP. I just found some example in Java but it wasn't very clear and didn't help much.

Any news on the toolkit release date?

--Alex

msimondsmsimonds
Nothint yet, I am in discussion with Nick to try and get a beta version


Mike