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
juppyjuppy 

Webservices - problems converting an inheritance relationship into the Apex equivalent

Having a frustrating time trying to create an interface to another database.

The other system has a wsdl like this:

 

<xs:complexType name="createIdentityResponse">
  <xs:complexContent>
    <xs:extension base="tns:response">
      <xs:sequence>
        <xs:element minOccurs="0" name="identityDetails" type="tns:identityDetails"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

 

From this, wsdl2apex creates this apex:

 

    public class response
    {
        public ServiceIdentitymanagemen.errors_element errors;
        private String[] errors_type_info = new String[]{'errors','urn:xxxx:service:identitymanagement:1.0','errors_element','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:xxxx:service:identitymanagement:1.0','false','false'};
        private String[] field_order_type_info = new String[]{'errors'};
    }

    public class errors_element
    {
        public ServiceIdentitymanagemen.error[] error;
        private String[] error_type_info = new String[]{'error','urn:xxxx:service:identitymanagement:1.0','error','0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:xxxx:service:identitymanagement:1.0','false','false'};
        private String[] field_order_type_info = new String[]{'error'};
    }

    public class createIdentityResponse response
    {
        public ServiceIdentitymanagemen.identityDetails identityDetails;
        private String[] identityDetails_type_info = new String[]{'identityDetails','urn:xxxx:service:identitymanagement:1.0','identityDetails','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:xxxx:service:identitymanagement:1.0','false','false'};
        private String[] field_order_type_info = new String[]{'identityDetails'};
    }

 

Note that there is no apparent link between response (which has error details) and the createIdentityResponse which has details of the successfully created record. Consequently at runtime I get the error:

Unable to parse callout response. Apex type not found for element errors

 

I've seen similar problems described in this forum but none with an answer; I'm hoping someone can help with this because it seems to me all I need to do is establish the inheritance relationship between 'response' and 'createIdentityResponse', something like this:

 

public class createIdentityResponse extends response

 

Unfortunately, that didn't seem to work for me. Any better ideas? I'm running up against a hard deadline here so any help appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
juppyjuppy

Extending the response class didn't work, so I tried incorporating the errors_element it references into the method return class, like this:

    public class createIdentityResponse
    {
        public ServiceIdentitymanagement.identityDetails identityDetails;
        public ServiceIdentitymanagement.errors_element errors;
        private String[] identityDetails_type_info = new String[]{'identityDetails','urn:xxx:service:identitymanagement:1.0','identityDetails','0','1','false'};
        private String[] errors_type_info = new String[]{'errors','urn:xxx:service:identitymanagement:1.0','errors_element','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:xxx:service:identitymanagement:1.0','false','false'};
        private String[] field_order_type_info = new String[]{'identityDetails, errors'};
    }

and that seems to have done the trick - I can now successfully deconstruct the reposnse and retrieve the error code and error message.

 

Hope this helps others faced with the same issue.