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
carriexcarriex 

Error when generate Apex code from WSDL for calling external web service

Get following error when generate apex class from wsdl file. Could anyone please help provide some insight? Thanks!
 
The following generated class(es) have compilation errors:
Error: inthubCrmserviceWsdl
Error: Dependent class is invalid and needs recompilation:
inthubCrmserviceTypes: line 34, column 18: inthubCrmserviceTypes.IntHubException: Exception class must extend another Exception class at 12:13
 
//Generated by wsdl2apex
public class inthubCrmserviceWsdl {
    public class CrmProcessorPort {
        public String endpoint_x = 'http://dapp1:57050//CRMService';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/wsdl', 'inthubCrmserviceWsdl', 'http://inthub.prod.netsol.com/CRMService/types', 'inthubCrmserviceTypes'};
        public void submitForm(inthubCrmserviceTypes.Credential Credential_1,inthubCrmserviceTypes.FormRequest FormRequest_2) {
            inthubCrmserviceTypes.submitForm request_x = new inthubCrmserviceTypes.submitForm();
            inthubCrmserviceTypes.submitFormResponse response_x;
            request_x.Credential_1 = Credential_1;
            request_x.FormRequest_2 = FormRequest_2;
            Map<String, inthubCrmserviceTypes.submitFormResponse> response_map_x = new Map<String, inthubCrmserviceTypes.submitFormResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://inthub.prod.netsol.com/CRMService/types',
              'submitForm',
              'http://inthub.prod.netsol.com/CRMService/types',
              'submitFormResponse',
              'inthubCrmserviceTypes.submitFormResponse'}
            );
            response_x = response_map_x.get('response_x');
        }
    }
}

Error: inthubCrmserviceTypes
Error: inthubCrmserviceTypes.IntHubException: Exception class must extend another Exception class at 34:18
//Generated by wsdl2apex
public class inthubCrmserviceTypes {
    public class submitForm {
        public inthubCrmserviceTypes.Credential Credential_1;
        public inthubCrmserviceTypes.FormRequest FormRequest_2;
        private String[] Credential_1_type_info = new String[]{'Credential_1','http://inthub.prod.netsol.com/CRMService/types','Credential','1','1','true'};
        private String[] FormRequest_2_type_info = new String[]{'FormRequest_2','http://inthub.prod.netsol.com/CRMService/types','FormRequest','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'Credential_1','FormRequest_2'};
    }
    public class Credential {
        public String password;
        public String userName;
        private String[] password_type_info = new String[]{'password','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] userName_type_info = new String[]{'userName','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'password','userName'};
    }
    public class FormRequest {
        public String action;
        public String clientRef;
        public inthubCrmserviceTypes.FormData[] formData;
        public String productInstanceId;
        public String webformInstanceId;
        private String[] action_type_info = new String[]{'action','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] clientRef_type_info = new String[]{'clientRef','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] formData_type_info = new String[]{'formData','http://inthub.prod.netsol.com/CRMService/types','FormData','0','-1','true'};
        private String[] productInstanceId_type_info = new String[]{'productInstanceId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] webformInstanceId_type_info = new String[]{'webformInstanceId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'action','clientRef','formData','productInstanceId','webformInstanceId'};
    }
    public class IntHubException {
        public Integer errorCode;
        public String vendorErrorCode;
        public String vendorErrorMessage;
        public String message;
        private String[] errorCode_type_info = new String[]{'errorCode','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] vendorErrorCode_type_info = new String[]{'vendorErrorCode','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] vendorErrorMessage_type_info = new String[]{'vendorErrorMessage','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] message_type_info = new String[]{'message','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'errorCode','vendorErrorCode','vendorErrorMessage','message'};
    }
    public class submitFormResponse {
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class FormData {
        public String answer;
        public String name;
        public String question;
        private String[] answer_type_info = new String[]{'answer','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] name_type_info = new String[]{'name','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] question_type_info = new String[]{'question','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://inthub.prod.netsol.com/CRMService/types','false'};
        private String[] field_order_type_info = new String[]{'answer','name','question'};
    }
}
carriexcarriex
The WSDL file is posted here:

<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://inthub.prod.netsol.com/CRMService/wsdl" xmlns:ns2="http://inthub.prod.netsol.com/CRMService/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="CRMService" targetNamespace="http://inthub.prod.netsol.com/CRMService/wsdl">
  <types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://inthub.prod.netsol.com/CRMService/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://inthub.prod.netsol.com/CRMService/types">
      <complexType name="Credential">
        <sequence>
          <element name="password" type="string" nillable="true"/>
          <element name="userName" type="string" nillable="true"/></sequence></complexType>
     <complexType name="IntHubException">
        <sequence>
          <element name="errorCode" type="int"/>
          <element name="vendorErrorCode" type="string" nillable="true"/>
          <element name="vendorErrorMessage" type="string" nillable="true"/>
          <element name="message" type="string" nillable="true"/></sequence></complexType>
   <complexType name="submitForm">
        <sequence>
          <element name="Credential_1" type="tns:Credential" nillable="true"/>
          <element name="FormRequest_2" type="tns:FormRequest" nillable="true"/></sequence></complexType>
      <complexType name="FormRequest">
        <sequence>
          <element name="action" type="string" nillable="true"/>
          <element name="clientRef" type="string" nillable="true"/>
          <element name="formData" type="tns:FormData" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
          <element name="productInstanceId" type="string" nillable="true"/>
          <element name="webformInstanceId" type="string" nillable="true"/></sequence></complexType>
      <complexType name="FormData">
        <sequence>
          <element name="answer" type="string" nillable="true"/>
          <element name="name" type="string" nillable="true"/>
          <element name="question" type="string" nillable="true"/></sequence></complexType>
      <complexType name="submitFormResponse">
        <sequence/></complexType>
      <element name="submitForm" type="tns:submitForm"/>
      <element name="submitFormResponse" type="tns:submitFormResponse"/>
      <element name="IntHubException" type="tns:IntHubException"/>
     </schema></types>
  <message name="IntHubException">
    <part name="IntHubException" element="ns2:IntHubException"/></message>
  <message name="CrmProcessor_submitForm">
    <part name="parameters" element="ns2:submitForm"/></message>
  <message name="CrmProcessor_submitFormResponse">
    <part name="result" element="ns2:submitFormResponse"/></message>
  <portType name="CrmProcessor">
    <operation name="submitForm">
      <input message="tns:CrmProcessor_submitForm"/>
      <output message="tns:CrmProcessor_submitFormResponse"/>
      <fault name="IntHubException" message="tns:IntHubException"/></operation></portType>
  <binding name="CrmProcessorBinding" type="tns:CrmProcessor">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="submitForm">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/></input>
      <output>
        <soap:body use="literal"/></output>
      <fault name="IntHubException">
        <soap:fault name="IntHubException" use="literal"/></fault></operation></binding>
  <service name="CRMService">
    <port name="CrmProcessorPort" binding="tns:CrmProcessorBinding">
      <soap:address location="http://dapp1:57050//CRMService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/></port></service></definitions>

cheenathcheenath
<complexType name="IntHubException">

This complex type is generating a class with name Exception and Apex do not
allow a non exception class to end with exception.

If you can change the service, then change IntHubException to something else
say, IntHubError.

If you cant change the service, i think just changing the complexType name in
your local wsdl will do. complexType name is not part of xml written on wire.

HTHs,



Pooja05Pooja05

Hey,

 

We are consuming a wsdl which has implemented
exception handling. But Apex doesnt handle the exception classes How
can we take care of exceptions in such situations? Are there any work
arounds.

 

The client wants us to tell the exact the problem that occured rather than throwing a generic callout exception.

 

Can you please help us with this issue?



 

 

Seb OrtizSeb Ortiz

I edited the generated exception class to extend it from the Apex Exception class and it made the trick.

So here is how I left the class:

 

public class ZSdoaCreateOrderWsV13_RfcException extends Exception {

}

 

Regards

Sebastian

 

riffindusriffindus

Hi Sebastian,

 

I added "extends exception" for a class which was generated from my WSDL and it was throwing an compilation error as

 

ClaimsDataBaseNotAvailableException: Exception class must extend another Exception class at 4:18

 

so i added "extends exception" to this class and clicked on "done" link.

 

But the class is not reflecting in the Apex class list.

 

I tried many times but the same happening. What to do?

ScriptMonkeyScriptMonkey

riffindus wrote:

Hi Sebastian,

 

I added "extends exception" for a class which was generated from my WSDL and it was throwing an compilation error as

 

ClaimsDataBaseNotAvailableException: Exception class must extend another Exception class at 4:18

 

so i added "extends exception" to this class and clicked on "done" link.

 

But the class is not reflecting in the Apex class list.

 

I tried many times but the same happening. What to do?


I looked into this myself on a similiar issue.  The problem seems to be salesforce syntax.

 

you cannot end a class with the word "Exception" unless it exends the exception class.  Change the class name so it doesn't say Exception at the end (ExceptionWSDL for example) and it doesn't need to extend anything.

 

Let me know if this fixes the issue.

Jessica Colson 7Jessica Colson 7

In regards to riffindus comment above, it wouldn't work because making the change in that little text box does not do anything. You would have to create the Apex classes yourself, copy in the code in those text boxes, make your changes, then save. What they show you when there are errors is what they would have created if there were no errors, but they don't actually create those classes if an error occurs.