How to create a Web service in Salesforce for external system calls

Source: Internet
Author: User
Tags soap wsdl

Web service can be created in Salesforce for external system calls, and the calling interface can be provided externally as soap or rest, followed by a detailed description of how to create a Web in soap Service and make a simple call with a asp.net program.

1): Create the following class in Salesforce

"NOTE: If you want to make it a Web service, then class must be defined as global, with the specific method of webService static modifier"

"The code omits the specific implementation of the Generateaccountfromxmlinfo method, see the details: http://www.cnblogs.com/mingmingruyuedlut/p/3497646.html"

Global class Sfaccountwebservice {
        
    webService static string Upsertaccount (String accountxmlinfo) {
        account CURRENTACC = Generateaccountfromxmlinfo (accountxmlinfo);
        Try
        {account
            acc = [Select Id from Account a Where AccountNumber =: Currentacc.accountnumber];
            if (ACC!= null) {
                currentacc.id = Acc. Id;
            }
            Upsert CURRENTACC;
            Return ' true ';
        }
        catch (Exception ex) {return
            ' false ';    
        }
    }
        
        
    private static Account Generateaccountfromxmlinfo (String accountxmlinfo) {account
        CURRENTACC = new account ();
        Parse the XML info to generate the account Object return
        CURRENTACC
    }
        
}

2): after saving the class above, we found the class just saved in the setup--> build--> develop--> apex classes. We will find that there is a WSDL option in the corresponding action, which is Salesforce by default to convert the class of the Web service into a WSDL file. As shown in the following figure

3): Click on the WSDL button above, you will see the following interface, which shows the generated WSDL file details, we click the right mouse button to save this file to local, this is named sfaccountwebservice.wsdl

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.