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