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
Dhaval PanchalDhaval Panchal 

Urgent, Need to develop Salesforce Webservice.



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 = '';
            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;
            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.


   <faultstring>content-type of the request should be                 text/xml</faultstring>


below is my code to access web service


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<title>Untitled Document</title>
  <form name="myform" 
            <!--<input type="hidden"  name="LeadId" value="<soap><body><LeadId>00Q90000003d8lN</LeadId></soap></body>" />-->
            <textarea rows="20" cols="100" name="LeadId">
                <?xml version="1.0"?>
			<!--<label for="first_name">Lead Id</label>
			<input  id="LeadId" maxlength="40" name="LeadId" size="20" type="text" /><br>-->
            <input type="submit" value="Submit">


any one can help me on this?




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 PanchalDhaval Panchal
Actually I want to use it outside of salesforce. So I cannot create VF page.
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?