function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Swamy P R NSwamy P R N 

Apex Webservice with the security of username and password

Hello everyone,

I have the below webservice class, but i just gave account insertion in that class. No where mentioned the username and password also. So are Third people directly invoke this code in their system?. Once they call that method is Account is going to insert in Salesforce??
Please give me some idea on this code and how can i do the integration by using webservice also?

global class AccountPlan {
      webservice String area;
      webservice String region;
//Define an object in apex that is exposed in apex web service
 global class Plan {
        webservice String name;
        webservice Integer planNumber;
        webservice Date planningPeriod;
       webservice Id planId;
  }

webservice static Plan createAccountPlan(Plan vPlan) {
     Account acct = new Account();
     acct.Name = vPlan.name;
     acct.AccountNumber = String.valueOf(vPlan.planNumber);
  insert acct;
 vPlan.planId=acct.Id;
 return vPlan;
}
}

Thanks in advance!!
NagaNaga (Salesforce Developers) 
Hi Swamy,

Apex supports HTTP Services with several built in Apex classes to creating HTTP requests like GET, POST, PUT, and DELETE. There are 3 main classes:

HTTP Class: Use this class to initiate an HTTP request and response.
HttpRequest Class: Use this class to programmatically create HTTP requests.
HttpResponse Class: Use this class to handle the HTTP response returned by the HTTP.Send() operation.

Together, these classes support the ability to develop HTTP request/response functionality within Apex. Using these HTTP classes supports the ability to integrate to REST-based services. It also enables the ability to integrate to SOAP-based web services as an alternate option to leveraging WSDL2Apex. By using the HTTP classes, instead of WSDL2Apex, the developer has more responsibility to handling the construction of the SOAP message both for the request and the response. 

The following sections will show a few examples of how to use these classes to make a REST-based web service call. Check out projects on Code Share for more code - for example the Force.com Toolkit for Google Data APIs makes extensive use of these types of callouts.

Please follow the below two links and i think you should be able to find something 

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008wTTIAY

https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts

Best Regards
Naga Kiran
Swamy P R NSwamy P R N
Hi Naga,

As i mentioned in the above post, If 3rd party people invoked above class than what is the use of it? 
Are they going to have records whenver salesforce creates Account records? 

In my scenario i have to do the integration with SAP system by using Apex web services only. So how can i achieve this? and what is the above class functionality?

Please help me out.