[SalesForce] Error in Generate WSDL: Apex Generation Failed Unable to find complexType for {http://soap.sforce.com..}RelationshipReferenceTo

I'm trying to Generate from WSDL. I have created a WSDL for one class containing webservice methods (MyClass) and now generating the class from wsdl in another org. Initially I was getting error

Unable to find complexType for
{http://soap.sforce.com/schemas/class/MyClass}RelationshipReferenceTo

After doing some R&D, I found that we can resolve this error by replacing tns:RelationshipReferenceTo to xsd:string but after updating it and parsing the XML I'm getting new error for RecordType

Unable to find complexType for
{http://soap.sforce.com/schemas/class/MyClass}RecordTypesSupported

Don't know why it required to change everything to xsd:string and also would it effect the functioning of webservice methods as I'm also working with record types and reference entities (like : Look-up & M-D relationships).

Trying to share some part of wsdl where error is occurring.

<xsd:complexType name="EntityDefinition">

<xsd:complexContent>
<xsd:extension base="tns:sObject">
<xsd:sequence>
<xsd:element name="ChildRelationships" minOccurs="0" type="tns:QueryResult" nillable="true"/>
<xsd:element name="DefaultCompactLayoutId" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="DetailUrl" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="DeveloperName" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="DurableId" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="EditDefinitionUrl" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="EditUrl" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="Fields" minOccurs="0" type="tns:QueryResult" nillable="true"/>
<xsd:element name="HelpSettingPageName" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="HelpSettingPageUrl" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="IsApexTriggerable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsCompactLayoutable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsCustomSetting" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsCustomizable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsDeprecatedAndHidden" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsEverCreatable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsEverDeletable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsEverUpdatable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsFeedEnabled" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsIdEnabled" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsLayoutable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsQueryable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsReplicateable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsRetrieveable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsSearchLayoutable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsSearchable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsTriggerable" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="IsWorkflowEnabled" minOccurs="0" type="xsd:boolean" nillable="true"/>
<xsd:element name="KeyPrefix" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="Label" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="LastModifiedBy" minOccurs="0" type="tns:User" nillable="true"/>
<xsd:element name="LastModifiedById" minOccurs="0" type="tns:ID" nillable="true"/>
<xsd:element name="LastModifiedDate" minOccurs="0" type="xsd:dateTime" nillable="true"/>
<xsd:element name="MasterLabel" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="NamespacePrefix" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="NewUrl" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="Particles" minOccurs="0" type="tns:QueryResult" nillable="true"/>
<xsd:element name="PluralLabel" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="Publisher" minOccurs="0" type="tns:Publisher" nillable="true"/>
<xsd:element name="PublisherId" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="QualifiedApiName" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="RecordTypesSupported" minOccurs="0" type="tns:RecordTypesSupported" nillable="true"/>
<xsd:element name="RelationshipDomains" minOccurs="0" type="tns:QueryResult" nillable="true"/>
<xsd:element name="RunningUserEntityAccess" minOccurs="0" type="tns:UserEntityAccess" nillable="true"/>
<xsd:element name="RunningUserEntityAccessId" minOccurs="0" type="xsd:string" nillable="true"/>
<xsd:element name="SearchLayouts" minOccurs="0" type="tns:QueryResult" nillable="true"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

Any comments are appreciated!!

Best Answer

I'd need to see how the RecordTypesSupported complex type is defined to know what the problem is there.

I noticed in your your extract from the WSDL that it includes <xsd:extension base="tns:sObject">. That means that EntityDefinition extends the elements from sObject. The native Wsdl2Apex implementation doesn't support this.

I've made an alternative version of WSDL2Apex that has increased support for various WSDL elements, including xsd:extension. You can get the FuseIT SFDC Explorer for free.

If you can share your complete WSDL I'll give it a quick check.

Related Topic