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
Alexander A 7Alexander A 7 

how to call the web services in apex class

Hi, All I'm Fresher in Salesforce.Start Learning about Integration in salesforce and I know what is integration I want to learn more implement the integration in Salesforce anyone has open web service URL. if you have Kindly give me help to learn integration and one more thing is

*using apex class how to consume the web services?
*how to call the web services Method?
*what are all the Procedure to implement the integration using web services URL?
*Clicking the button in the visualforce page how to call the web services and how to retrieve the data to display?
* any sample code is there?

Advance Thanks  To all
Aslam ChaudharyAslam Chaudhary
HttpRequest req = new HttpRequest(); 
 
  //Set HTTPRequest Method
  req.setMethod('PUT');

  //Set HTTPRequest header properties
  req.setHeader('content-type', 'image/gif');
  req.setHeader('Content-Length','1024');
  req.setHeader('Host','s3.amazonaws.com');
  req.setHeader('Connection','keep-alive');
  req.setEndpoint( this.serviceEndPoint + this.bucket +'/' + this.key);
  req.setHeader('Date',getDateString()); 

  //Set the HTTPRequest body	
  req.setBody(body); 	

  Http http = new Http();
  
   try {
 
        //Execute web service call here		
        HTTPResponse res = http.send(req);	

        //Helpful debug messages
        System.debug(res.toString());
        System.debug('STATUS:'+res.getStatus());
        System.debug('STATUS_CODE:'+res.getStatusCode());
		
} catch(System.CalloutException e) {
	//Exception handling goes here....
}

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

HTH!
Maria AlexanderMaria Alexander
Hi Alexander

Good Question I'm also searching the same questions.