Loading
Ongoing maintenance for Salesforce HelpRead More
Feature degradation | Gmail Email delivery failureRead More
Enhance Salesforce with Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create an Apex Class from a WSDL

          Create an Apex Class from a WSDL

          An Apex class can be automatically generated from a WSDL document that is stored on a local hard drive or network.

          Required Editions

          Available in: Salesforce Classic (not available in all orgs) and Lightning Experience
          Available in: Enterprise, Performance, Unlimited, Developer, and Database.com Editions
          User Permissions Needed
          To define, edit, delete, set security, and set version settings for Apex classes: Author Apex
          To run Apex tests: View Setup and Configuration

          Creating a class by consuming a WSDL document allows developers to make callouts to the external Web service in their Apex.

          Note
          Note Use Outbound Messaging to handle integration solutions when possible. Use callouts to third-party Web services only when necessary.
          1. In the application, from Setup, enter Apex Classes in the Quick Find box, then select Apex Classes.
          2. Click Generate from WSDL.
          3. Click Browse to navigate to a WSDL document on your local hard drive or network, or type in the full path. This WSDL document is the basis for the Apex class you are creating.
            Note
            Note

            The WSDL document that you specify might contain a SOAP endpoint location that references an outbound port.

            For security reasons, Salesforce restricts the outbound ports you can specify to one of the following:

            • 80: This port only accepts HTTP connections.
            • 443: This port only accepts HTTPS connections.
            • 1024–66535 (inclusive): These ports accept HTTP or HTTPS connections.
          4. Click Parse WSDL to verify the WSDL document contents. The application generates a default class name for each namespace in the WSDL document and reports any errors. Parsing fails if the WSDL contains schema types or constructs that aren’t supported by Apex classes, or if the resulting classes exceed the 1 million character limit on Apex classes. For example, the Salesforce SOAP API WSDL cannot be parsed.
          5. Modify the class names as desired.
            While you can save more than one WSDL namespace into a single class by using the same class name for each namespace, Apex classes can be no more than 1 million characters total.
          6. Click Generate Apex. The final page of the wizard shows which classes were successfully generated, along with any errors from other classes. The page also provides a link to view successfully generated code.

          The successfully generated Apex classes include stub and type classes for calling the third-party Web service represented by the WSDL document. These classes allow you to call the external Web service from Apex. For each generated class, a second class is created with the same name and with a prefix of Async. The first class is for synchronous callouts. The second class is for asynchronous callouts. For more information, see the Apex Code Developer's Guide.

          Note the following about the generated Apex:

          • If a WSDL document contains an Apex reserved word, the word is appended with _x when the Apex class is generated. For example, limit in a WSDL document converts to limit_x in the generated Apex class. For a list of reserved words, see the Apex Code Developer's Guide.
          • If an operation in the WSDL has an output message with more than one element, the generated Apex wraps the elements in an inner class. The Apex method that represents the WSDL operation returns the inner class instead of the individual elements.
           
          Loading
          Salesforce Help | Article