+ Start a Discussion
Chitral ChaddaChitral Chadda 

apexx web services and callouts

what are apex web services and callouts ,http request ?

i tried goin thru links bt couldnt undstnd ,  dnt post links
pls xplain in general terms so that i can hv a clear understanding of these.
Best Answer chosen by Chitral Chadda
asish1989asish1989
Suppose there are two differeent environment  say salesforce and PHP

Web services API

You have developed an application(Recruiting Apps) in salesforce , Some customers who are in PHP environment want to use it. how can they use your Apps?

For this propose you need to develope an webservice API (REST or SOAP ) so that they will access your Recruiting Apps easily.

If you develope a REST api then you need to create an endpoint url and need to give them so that they will hit the end point url and can do needful.

Go through this link 
https://developer.salesforce.com/page/Creating_REST_APIs_using_Apex_REST

if you develop a SOAP api then you need to generate WSDL file and provide them so that they will compose wsdl file and will generate a proxy class to access your Recruit Apps.

Go through this link 
http://www.salesforce.com/us/developer/docs/api/

For security propose you need to create a Connected Apps and need to give a call back url.


External Callout

You want to call an externcal application say one Payment getway you want to integrate with your apps. 

In that case you need to go for call out. That means external environment will give thier webservices (Rest or SOAP) you need to call them. It is recomonded generally we integarte restfil webserivices. 

Before doing call out first you need to register endpoint Url in remort site in salesforce. Then you need to write http method to call external application. 

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm

http://blog.jeffdouglas.com/2009/03/16/restful-web-service-callout-using-post/

All Answers

sweetzsweetz
Apex Web Service - To expose apex methods as a web service - i.e., creating a web service that a client can invoke. [Apex Web Services allows an external application to invoke Apex methods through web services]
Callouts -  To invoke external web services. [connect with third party services]
HTTP Request - To invoke the external web services.
asish1989asish1989
Suppose there are two differeent environment  say salesforce and PHP

Web services API

You have developed an application(Recruiting Apps) in salesforce , Some customers who are in PHP environment want to use it. how can they use your Apps?

For this propose you need to develope an webservice API (REST or SOAP ) so that they will access your Recruiting Apps easily.

If you develope a REST api then you need to create an endpoint url and need to give them so that they will hit the end point url and can do needful.

Go through this link 
https://developer.salesforce.com/page/Creating_REST_APIs_using_Apex_REST

if you develop a SOAP api then you need to generate WSDL file and provide them so that they will compose wsdl file and will generate a proxy class to access your Recruit Apps.

Go through this link 
http://www.salesforce.com/us/developer/docs/api/

For security propose you need to create a Connected Apps and need to give a call back url.


External Callout

You want to call an externcal application say one Payment getway you want to integrate with your apps. 

In that case you need to go for call out. That means external environment will give thier webservices (Rest or SOAP) you need to call them. It is recomonded generally we integarte restfil webserivices. 

Before doing call out first you need to register endpoint Url in remort site in salesforce. Then you need to write http method to call external application. 

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm

http://blog.jeffdouglas.com/2009/03/16/restful-web-service-callout-using-post/

This was selected as the best answer
Chitral ChaddaChitral Chadda
@asish1989

thnx so much fr ur help.

it means that in webservice we let xtrnal appltnion access our data thru webservice method we define.

like if i take input as lead with fields email,name,phone and thn create account,contact ,opportunit it wud code like this

global class WebExample
{
    webService static Account createRecords(Lead vLead) {
        Account acc = new Account();
        acc.Name = vLead.Lastname;
        acc.Phone = vLead.Phone;
        insert acc;
       
        Opportunity opp = new Opportunity();
        opp.Name = acc.Name+' '+'Opty Name';
        opp.Amount = vLead.AnnualRevenue;       
        insert opp;
       
        Contact con = new Contact();
        con.FirstName = 'test';
        con.LastName = vLead.LastName;
        con.Email = vLead.Email;
        con.Phone = vLead.Phone;
        insert con;
        system.debug('*********'+con);
       
        return acc;
    }
}



and in callout we use the 3rd party web services ( genraaly we use REST  for this callouts)
asish1989asish1989
@Chitral Chadda

Yeah absolutely right. 

Important :

If this is what you where looking for then please mark it as a solution for others benefits.

Thank You
Chitral ChaddaChitral Chadda
@asish1989
1 thing
global class WebExample
{
    webService static Account createRecords(Lead vLead) {
        Account acc = new Account();
        acc.Name = vLead.Lastname;
        acc.Phone = vLead.Phone;
        insert acc;
      
        Opportunity opp = new Opportunity();
        opp.Name = acc.Name+' '+'Opty Name';
        opp.Amount = vLead.AnnualRevenue;      
        insert opp;
      
        Contact con = new Contact();
        con.FirstName = 'test';
        con.LastName = vLead.LastName;
        con.Email = vLead.Email;
        con.Phone = vLead.Phone;
        insert con;
        system.debug('*********'+con);
      
        return acc;
    }
}



shudnt this be 
webService static Lead createRecords(Lead vLead)

rather than account
webService static account createRecords(Lead vLead)
 
and also
i m lil confused like on this
webService static Lead createRecords(Lead vLead)
what object we take and what do we pass in parameters