Posts

Showing posts with the label SOAP

Authenticate using the SOAP login request

Login using the SOAP login request and from then on use the session token for making REST API requests.In this we need to pass Username and Password as credentials.Upon invocation, the API authenticates the credentials . It then returns the  sessionId , the user ID associated with the logged-in username, and a URL that points to the Lightning Platform API to use in all subsequent API calls.If Salesforce returns a Login fault , try adding the security token at the end of the user’s password.  The limit is 3,600 calls to login() per user per hour. Exceeding this limit results in a “Login Rate Exceeded” error. After reaching the hourly limit, Salesforce blocks the user from logging in. Users can try to log in again an hour after the block occurred. Sample Code -             HTTPRequest request = new HTTPRequest();             String username = 'rpatnaik@docmation.com';            ...

Salesforce EntityDefinition

Image
EntityDefinition Provides row-based access to metadata about standard and custom objects. EntityDefinition Note EntityDefinition fields are exposed in SOAP API version 45.0 and later. You can use Tooling API to query for EntityDefinition fields in guest user mode in API version 44.0 and earlier. In API version 45.0 and later, use SOAP API to get this data in guest user mode. EntityDefinition is still exposed in Tooling API to User Profiles with the ViewSetup permission.

Exposing Apex Methods as SOAP Web Services

By exposing them as SOAP web services, apex methods are available to external applications. To make Apex methods available as SOAP web services, we must declare them within a global Apex class and use the "webservice" keyword. Salesforce will then automatically create a WSDL document for that class, which can be utilized by external applications to access the exposed web services. Example global class MyWebService {     webservice static Id makeContact(String contactLastName, Account a) {         Contact c = new Contact(lastName = contactLastName, AccountId = a.Id);         insert c;         return c.id;     } } To generate the WSDL file for a Salesforce instance, we can simply append "?wsdl" to the instance URL, followed by the path to the Apex class.  For example, the URL should look like https://yourinstance.salesforce.com/services/wsdl/class/MyWebService. Once you have the WSDL file, you can generat...

Overview of Salesforce Apex REST and SOAP APIs:

Salesforce provides two primary mechanisms for integrating with external systems: REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) APIs. Both REST and SOAP APIs allow you to interact with Salesforce data and metadata programmatically, including querying, creating, updating, and deleting records. Here's an overview of Salesforce Apex REST and SOAP APIs: Apex REST (RESTful Web Services): Description: Apex REST allows you to expose custom RESTful web services within Salesforce. You can define custom REST endpoints using Apex classes and methods, which can then be invoked by external systems using HTTP requests. Usage: Apex REST is well-suited for building lightweight, stateless APIs that adhere to RESTful principles. It's commonly used for integrating with mobile applications, external web services, and other systems that communicate over HTTP. Authentication: Apex REST supports various authentication mechanisms, including OAuth 2.0, Session ID, and ...

Validate Salesforce User

Image
 Here's a piece of code to verify the password of a user.            HttpRequest request = new HttpRequest();         request.setEndpoint('https://login.salesforce.com/services/Soap/u/22.0');         request.setMethod('POST');         request.setHeader('Content-Type', 'text/xml;charset=UTF-8');         request.setHeader('SOAPAction', '""');         request.setBody( prepareSoapLoginRequest ('me_raja1@test.com','QW@232323'));         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, String.valueOf(new Http().send(request).getBody())));  public static String  prepareSoapLoginRequest (String username, String password){         XmlStreamWriter w = new XmlStreamWriter();         w.writeStartElement('', 'login', 'urn:partner.soap.sforce.com');         w.w...