You need to sign in to do that
Don't have an account?

Salesforce HTTP callout to Salesforce Site Web service
Hi all,
I'm working on a simple proof of concept project to help me understand web services better.
On the Salesforce Site side, I have the following web service:
global class helloWorld { WebService public static String GetMessage() { return 'Hello world'; } }
The corresponding site is http://mydomain.sandboxname.cs1.force.com/webservice.
The site's Active Site Home Page is set to a nearly blank page called test and I have enabled the above class within the site's Public Access Settings
On the VisualForce page side that I'm trying to make the call from, I have the following:
public string getContent(){ Http h = new http(); HttpRequest req = new HttpRequest(); //req.setEndpoint('http://mydomain.sandboxname.cs1.force.com/services/Soap/class/helloWorld'); req.setEndpoint('http://mydomain.sandboxname.cs1.force.com/webservice'); req.setMethod('POST'); req.setHeader('Content-Type', 'text/xml;charset=utf-8'); req.setHeader('Content-Length', '18'); req.setHeader('soapAction', 'https://cs1-api.salesforce.com/services/Soap/class/helloWorld'); HttpResponse res = h.send(req); system.debug('Body was: '+ res); system.debug('String was:' + res.getBody()); return res.getBody(); }
This is the portion I'm not sure of. Really just winging it. As it stands, I'm currently receiving this error:
System.CalloutException: Read timed out
I'm not sure what to put as my endpoint, nor am I sure about the header information. Previously, without the Content-Length, it complained.
Within the WSDL for the class, I see "http://soap.sforce.com/schemas/class/helloWorld" and "https://cs1-api.salesforce.com/services/Soap/class/helloWorld" but not sure if those come into play.
I've successfuly called out to an externally hosted web service and had a much more complex request body, but was able to put it together using another example on the web.
Can any of you school me on what I'm doing wrong or point me in the direction of good example?
Thanks!
Here's what I got to work:
And for good measure, here is another test I did to create a first and last name to the webservice, create a contact, and return the new contact record's ID.
VF Page:
Class:
Web Service:
hi i am new to the integration and i went through your question and found intresting and hope for the help from you i am writing this could you please explain the process and a scenario in detail that i could understand how the integration is being carried out. I will be very glad if you could help.
thank you
suree
I really want to know if you can call the Apex WS from the HTTP callout.
Thanks ahead.