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
thangasan@yahoothangasan@yahoo 

Creating Custom Object programmatic using Metadata API

Hi
 
  For Creating Custom Object programmatic using Metadata API I am receive the following Error Can any one help
 
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
 faultSubcode:
 faultString: Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element
 faultActor:
 faultNode:
 faultDetail:
 {http://xml.apache.org/axis/}stackTrace:Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element
 
here is the code
 
Code:
MetadataBindingStub stub = (MetadataBindingStub) new MetadataServiceLocator().getMetadata();
stub.setTimeout(60000);

// Login using Partner WSDL 
// Getting the Session ID from Partner WSDL


SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());

stub.setHeader(new MetadataServiceLocator().getServiceName()
  .getNamespaceURI(), "SessionHeader", sh);


CustomObject co = new CustomObject();
String name = "MyNewObj";
co.setFullName(name + "__c");
co.setDeploymentStatus(DeploymentStatus.Deployed);
co.setDescription("Created by the Metadata API");
co.setEnableActivities(true);
co.setLabel(name + " Object");
co.setPluralLabel(co.getLabel() + "s");
co.setSharingModel(SharingModel.ReadWrite);
CustomField nf = new CustomField();
nf.setType(FieldType.Text);
nf.setLabel(co.getFullName() + " Name");
co.setNameField(nf);
AsyncResult[] ars = stub.create(new Metadata[] { co} );

 
Note SessionHeader Class also Import from partner WSDL .
Metadata.wsdl not generating SessionHeader.java.
 
Thanks
Thanga
 
SuperfellSuperfell
Depending on which exact version of Axis you're using you may need to do this instead.
AsyncResult[] ars = stub.create(new CustomObject[] { co} );

thangasan@yahoothangasan@yahoo

Sir

I tried what you said but i got the below Error , Sorry for late replay

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.io.IOException: java.io.IOException: java.io.IOException: Non nillable element 'fullName' is null.
 faultActor:
 faultNode:
 faultDetail:
 {http://xml.apache.org/axis/}stackTrace:java.io.IOException: java.io.IOException: java.io.IOException: Non nillable element 'fullName' is null.

I am setting fullname , And i am using Axis 10.0 ,

My URL is https://na4-api.salesforce.com/services/Soap/u/10.0

 

 

RamyaKrishnaRamyaKrishna

Could you plelase reply how can i retrieve all report names of salesforce meta data api from apex class (or) any other javascript function?