You need to sign in to do that
Don't have an account?
manjiri
Problem in Calling Yahoo web Service from Apex class
Hi,
I want to call Yahoo web service through REST protocol from my apex code.
I am using following example given in apex language reference guide. I have just replaced my url in the code.
public class HttpCalloutSample {
// Pass in the endpoint to be used using the string url
public String getContent() {
// 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();
String url = 'http://travel.yahooapis.com/TripService/V1.1/tripSearch?appid=YahooDemo';
req.setEndpoint(url);
req.setMethod('GET');
// Send the request, and return a response
HttpResponse res = h.send(req);
return res.getBody();
}
}
I am calling following line from my S-Control (in my javascript function)
var success = sforce.apex.execute("HttpCalloutSample", "getContent", {});
I am getting following exception.
faultcode soapenv:Client
faultstring No operation available for request {http://soap.sforce.com/schemas/package/HttpCalloutSample}getContent, please check the WSDL for the service.
So what is the problem? Is it a right way?
Does anyone have any example code or syntax show how I would make that call?
Thanks
I want to call Yahoo web service through REST protocol from my apex code.
I am using following example given in apex language reference guide. I have just replaced my url in the code.
public class HttpCalloutSample {
// Pass in the endpoint to be used using the string url
public String getContent() {
// 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();
String url = 'http://travel.yahooapis.com/TripService/V1.1/tripSearch?appid=YahooDemo';
req.setEndpoint(url);
req.setMethod('GET');
// Send the request, and return a response
HttpResponse res = h.send(req);
return res.getBody();
}
}
I am calling following line from my S-Control (in my javascript function)
var success = sforce.apex.execute("HttpCalloutSample", "getContent", {});
I am getting following exception.
faultcode soapenv:Client
faultstring No operation available for request {http://soap.sforce.com/schemas/package/HttpCalloutSample}getContent, please check the WSDL for the service.
So what is the problem? Is it a right way?
Does anyone have any example code or syntax show how I would make that call?
Thanks
[source]
global class HttpCalloutSample
{
// Pass in the endpoint to be used using the string url
WebService static String getContent()
{
// 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();
String url = 'http://travel.yahooapis.com/TripService/V1.1/tripSearch?appid=YahooDemo';
req.setEndpoint(url);
req.setMethod('GET');
// Send the request, and return a response
HttpResponse res = h.send(req);
return res.getBody();
}
}
[/source]
Review all error messages below to correct your data.
Apex trigger helloWorldAccountTrigger caused an unexpected exception, contact your administrator: helloWorldAccountTrigger: execution of BeforeInsert caused by: System.CalloutException: Callout from triggers are currently not supported.: Class.HttpCalloutSample.getContent: line 14, column 44
Now we are able to call webservice.