You need to sign in to do that
Don't have an account?
Dhaval Panchal
Urgent, Need to develop Salesforce Webservice.
Hello,
I want to create on webservice, which can be accessed from outside of salesforce to fatch salesforce data. I want this only for lead and opportunity object.
I have created below sample webservice
global class wsReadLeads{ webService static String readLead(String LeadId){ List<Lead> lstLead = [Select Id, Email, Status, Name, Phone From Lead Where Id=:leadId]; String strLead = ''; if(lstLead.size()>0){ strLead = 'Lead : ' + lstLead[0].Name; strLead += 'Status : ' + lstLead[0].Status; strLead += 'Email : ' + lstLead[0].Email; strLead += 'Phone : ' + lstLead[0].Phone; strLead += 'Id : ' + lstLead[0].Id; } else{ strLead = '<B>No lead found</B>'; } return strLead; } }
now i want to access it from out side (SAP). how should i do this?
I tried this using html form tag (using post method). it shows below error.
<soapenv:Envelope> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Client</faultcode> <faultstring>content-type of the request should be text/xml</faultstring> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>
below is my code to access web service
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> </head> <form name="myform" action="https://ap1.salesforce.com/services/Soap/class/wsReadLeads?un=test@xyz.com&pw=XXXXXX" method="POST"> <!--<input type="hidden" name="LeadId" value="<soap><body><LeadId>00Q90000003d8lN</LeadId></soap></body>" />--> <textarea rows="20" cols="100" name="LeadId"> <?xml version="1.0"?> <soapenv:Envelope> <soapenv:Body> <parameters> <LeadId>00Q90000003d8lN</LeadId> </parameters> </soapenv:Body> </soapenv:Envelope> </textarea> <!--<label for="first_name">Lead Id</label> <input id="LeadId" maxlength="40" name="LeadId" size="20" type="text" /><br>--> <input type="submit" value="Submit"> </form> </html>
any one can help me on this?
sfdcfox
You can't access a web service though an HTML form. That's not what they're designed to do. You need a Visualforce page.
Dhaval Panchal
Actually I want to use it outside of salesforce. So I cannot create VF page.
sfdcfox
You'll need to use some JavaScript or something, then. You can't just use a regular form. Perhaps you could be more specific on what you're attempting to do?