1

I am getting an issue while generating the WSDL for my custom SOAP Service. Earlier when I did back in 2018 I was able to generate the WSDL. Now, the issue that I am getting is when I click on generate WSDL then it generates the WSLD file for the whole org instead of that particular class only.

Below is my code

    global with sharing class AccountPlanner {
    
    webservice static String fullName(String firstName, String lastName){
        String greetMessage = 'Welcome '+firstName+' '+lastName;
        return greetMessage;
    }
    
    webservice static AccountWrapper createAccount(AccountWrapper accountRec){ 
    
        Account accRec = new Account();
        accRec.Name = accountRec.Name;
        accRec.Rating = accountRec.Rating;
        accRec.Industry = accountRec.Industry;
        accRec.Phone = accountRec.Phone;
        accRec.AccountNumber = accountRec.AccountNumber;
        
        insert accRec;
        Contact conRec = accountRec.contactRecord;
        conRec.AccountId = accRec.Id;
        insert conRec;
        
        return accountRec;
    }
    
    global class AccountWrapper {
    
        webservice String Name;
        webservice String Rating;
        webservice String Industry;
        webservice String Phone;
        webservice String AccountNumber;
        webservice Contact contactRecord;
        
    }

}

Any help will be appreciated.

Thanks in advance.

2
  • How are you generating the wsdl? I just tested this in my org, and it works the same as it always has.
    – sfdcfox
    Oct 25, 2020 at 15:30
  • 1
    I was trying from the free developer edition. I tried the Mohit solution and it worked it was because of the reference of standard object.
    – Amit Singh
    Oct 25, 2020 at 15:45

1 Answer 1

2

The issue is because you are referencing an object "Contact" of Salesforce Schema in your parameter accountRec for createAccount method and hence all related Standard objects are pulled as a dependency in the WSDL.

You can easily get away with it by not referencing any SObject in the Wrapper definition you have for the method parameter.

Check the below-modified code

global with sharing class AccountPlanner {

 webservice static String fullName(String firstName, String lastName){
     String greetMessage = 'Welcome '+firstName+' '+lastName;
     return greetMessage;
  }

  webservice static AccountWrapper createAccount(AccountWrapper accountRec){ 

    AccountWrapper accountResponse = new AccountWrapper();

    Account accRec = new Account();
    accRec.Name = accountRec.Name;
    accRec.Rating = accountRec.Rating;
    accRec.Industry = accountRec.Industry;
    accRec.Phone = accountRec.Phone;
    accRec.AccountNumber = accountRec.AccountNumber;
    
    insert accRec;
    Contact conRec = new Contact();
    conRec.LastName = accountRec.contactLastName;
    conRec.AccountId = accRec.Id;
    insert conRec;
    
    accountResponse = accountRec;
    
    return accountResponse;
    
}

global class AccountWrapper {

    webservice String Name;
    webservice String Rating;
    webservice String Industry;
    webservice String Phone;
    webservice String AccountNumber;
    webservice String contactLastName;
    
   }
 
 }

Carefully note how my Wrapper does not have any reference to an SObject. If you need to pass in a lot of attributes I suggest creating a ContactWrapper class as well as a part of the definition. This way the WSDL will have no reference to any standard objects.

1
  • It worked thanks for the quick turn around :)
    – Amit Singh
    Oct 25, 2020 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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