Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I've generated an Apex class based on the Metadata WSDL file I got from my org. I call the readMetadata function and while the response received contains all the data I want, the callout fails because of 'Apex type not found for element language'. What is missing from the generated code that it can't parse responses?

The response looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <readMetadataResponse>
            <result>
                <records xsi:type="CustomLabel">
                    <fullName>Accepted</fullName>
                    <language>en_US</language>
                    <protected>true</protected>
                    <shortDescription>Accepted</shortDescription>
                    <value>Accepted</value>
                </records>
                <records xsi:type="CustomLabel">
                    <fullName>Rejected</fullName>
                    <language>en_US</language>
                    <protected>true</protected>
                    <shortDescription>Rejected</shortDescription>
                    <value>Rejected</value>
                </records>
            </result>
        </readMetadataResponse>
    </soapenv:Body>
</soapenv:Envelope>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Andrew Fawcett has done a lot of work on using this API from Apex. Some of the issues are listed in his Challanges calling the Metadata API from Apex, such as polymorphic types that the Apex WSDL tooling can't handle.

So rather than the WSDL emitted by an org, that financialforcedev/apex-mdapi Git project is the best place to start.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.