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
NeeharikaNeeharika 

Callout to external webserivce

Hi,

 

Can someone help me with 'how to perform a callout to an external webservice from salesforce'.

Say I have got the WSDL. I generate Apex classes from it. Then what next?

How can I perform a call out? How to build the HTTP request? Please help me out!

Paste the sample code if possible. That would be helpful.

 

Thanks in Advance.

 

WEN JIEWEN JIE

Hi,

 

I hope this can help you.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts.htm

 

And you can sent HTTP request like this:

public class HttpCalloutSample {

// Pass in the endpoint to be used using the string url 
    
  public String getContent(String url) {

// Instantiate a new http object 
    
    Http h = new Http();

// Instantiate a new HTTP request, specify the method (GET) as well as the endpoint 
    
    HttpRequest req = new HttpRequest();
    req.setEndpoint(url);
    req.setMethod('GET');

// Send the request, and return a response 
    
    HttpResponse res = h.send(req);
    return res.getBody();
  }
}

 

NeeharikaNeeharika

Thanks a lot.

sfdcFanBoysfdcFanBoy

Similar case, I have generated the Apex Class by parsing the .net WSDL file. (wsdl2apex)

 

How do I use this generated apex class? This is a SOAP request, not by HTTP request.  How do I instantiate this class in another class to make callouts to the external webserivce?

 

Please let me know.

 

Thanks!