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
SrikanthKuruvaSrikanthKuruva 

Web service callout failed: Unable to parse callout response. Apex type not found for element

Hi All,

 

Following is the error that i have been facing 

"System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element".

i have the class defined for the element being pointed out in the above error. And also i dont have any invalid types in the wsdl like <s:any .... . So can you please let me know if there are any such  points that needs to be checked?

 

Thanks

Srikanth

sdetweilsdetweil

use the SoapUI tool to test your web service for proper handling..

 

SoapUI is just a google search away.

 

it is not free, but there is a trial use period..

 

Sam

SrikanthKuruvaSrikanthKuruva

yes the soap UI tool is giving me proper soap response but in SFDC along with the soap response i am getting the callout exception as "Web service callout failed: Unable to parse callout response. Apex type not found for element...."

sdetweilsdetweil

can u post your web service's WSDL?

 

SF doesn't support Soap 1.2 which might be causing this problem..

there is an Idea posted about this

 

http://success.salesforce.com/ideaview?id=08730000000BroSAAS

 

 

 

fgwarb_devfgwarb_dev
SrikanthKuruva, did you resolve this?  I've found many threads on this but none of their resolutions assisted.  public Boolean lenientParsing_x = true; in the wsdl2apex port class, homoginzing the namespaces.. etc.  In my instance the SFDC parser is failing on a virtual extension..

Error message: Web service callout failed: Unable to parse callout response. Apex type not found for element externalId

Here's the raw soap response up until the point of failure
<?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="CustomField">
     <fullName>Case.Custom_Field__c</fullName>
     <externalId>false</externalId>


And the apex classes for the parsing
public class readMetadataResponse_element {
        public SFDC_API_MetaData.ReadResult result;
        private String[] result_type_info = new String[]{'result','http://soap.sforce.com/2006/04/metadata','ReadResult','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/2006/04/metadata','true','false'};
        private String[] field_order_type_info = new String[]{'result'};
    }
    public class ReadResult {
        public SFDC_API_MetaData.Metadata[] records;
        private String[] records_type_info = new String[]{'records','http://www.w3.org/2001/XMLSchema','Metadata','0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/2006/04/metadata','true','false'};
        private String[] field_order_type_info = new String[]{'records'};
    }
    public virtual class Metadata {
        public String fullName;
        private String[] fullName_type_info = new String[]{'fullName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/2006/04/metadata','true','false'};
        private String[] field_order_type_info = new String[]{'fullName'};
    }
public class CustomField extends Metadata {
        public String type = 'CustomField';
        public String fullName;    
[...]
        public Boolean externalId;
[...]
        private String[] type_att_info = new String[]{'xsi:type'};               
[...]
        private String[] externalId_type_info = new String[]{'externalId','http://www.w3.org/2001/XMLSchema','boolean','0','1','false'};
[...]
    }


If I add "public boolean externalId;" to the Metadata class the error changes to the next "missing" field, which means that the parser is trying to create Metadata instances instead of CustomField instances.  I think the instruction to create CustomField instances is in the "xsi:type='CustomField'" attribute of the <records> tag, which uses a different namespace (which you can see I've been fiddling with). 

fgwarb_devfgwarb_dev
For anyone who comes across this in the future, I resolved the issue by deviating from the WSDL by changing

public class ReadResult {
        public SFDC_API_MetaData.Metadata[] records;
        private String[] records_type_info = new String[]{'records','http://www.w3.org/2001/XMLSchema','Metadata','0','-1','false'};
[...]

to

public class ReadResult {
        public SFDC_API_MetaData.CustomField[] records;
        private String[] records_type_info = new String[]{'records','http://www.w3.org/2001/XMLSchema','CustomField','0','-1','false'};
[...]

This means that each new read result query needs it's own classes to handle the response, but the use case we're solving focusing exclusively on custom fields.