• saravana
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi,
I am having a problem in making calls to webservice methods using the sforce.apex.execute method.
The exception i get is

Error {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', line:'1019', sourceURL:'https://na5.salesforce.com/soap/ajax/13.0/connection.js', }

I wrote a javascript to call webservice method passing arguments to save it in my server.
/////////////////////////////////////////////////////////////////////////////////////
function call()
{
var mess= sforce.apex.execute('MyController','getSend',{cname:document.getElementById('cname').value,email:document.getElementById('cmail').value,phone:document.getElementById('cphone').value,product:products});
}
/////////////////////////////////////////////////////////////////////////////////////

The controller contains the webservice method defined.
/////////////////////////////////////////////////////////////////////////////////////
WebService static String getSend(String cname,String email,String phone,String product) {
System.debug('inside send '+cname );
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
//req.setHeader('Cookie','sid='+UserInfo.getSessionId());
//+'&product='+product
req.setEndpoint('http://www.iclub.in/MRUserTrail/insert.html? userName='+UserInfo.getUserName()+'&cname='+cname+'&cemail='+email+'&cphone='+phone+'&product='+product);
HttpResponse res = h.send(req);
System.debug(res.getBody());
XmlStreamReader reader = res.getXmlStreamReader();

while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if(reader.getLocalName()=='status')
{
reader.next();
if(reader.getText()=='FAILURE')
{
reader.next();reader.next();reader.next();

return 'f$'+reader.getText();
}
if(reader.getText()=='SUCCESS')
{
reader.next();reader.next();reader.next();
return 's$'+reader.getText();
}
}
}
reader.next();
}
return 'f$Please try again after some time';
}
/////////////////////////////////////////////////////////////////////////////////////
I used this sforce.apex.execute because there was not way to call an controller method by passing
an argument's to it.I tried various ways of callling the controller but i could not do so. If it is
just an normal method without parameters then we can call it using !${Accounts.name}.

Q.Please tell me is there a way to call controller methods by passing parameters to it?

Q2.Please help me on this exception i am getting when calling the javascript function.

Thaking You everyone.
Hello,
 
I want to provide a hyperlink in my web page on clicking on this it should open the related record in salesforce window.
 
I am able to login to the salesforce and get the session id and the user information.
 
Please provide the information as early as possible.
 
 
Thanks,
Willy.S


Message Edited by willysam on 04-14-2008 02:36 AM

Message Edited by willysam on 04-14-2008 04:58 AM