• Ean9
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
When i update a picklist value from 'Requested' to 'Approved' then it should invoke a trigger which in turn calls an external web service (.net web application) and pass those data of the updated record along with it and those records should be received by the .net application and saved on sql server database. I am totally new to Salesforce and Web service.

Trigger,
trigger AdoDetailTrigger on PCS_Detail__c (after update)
{
List<PCS_Detail__c> pcsDetail = [Select Id,Tracking_Details__c From PCS_Detail__c Where Id IN :Trigger.new]; if(pcsDetail[0].Tracking_Details__c == 'Approved')
{
Set<Id> resultIds = (new Map<Id,SObject>(pcsDetail)).keySet();
InvokeWebServiceOnStatusChange.callWebService(resultIds);
}
}

Apex class future callout,
public class InvokeWebServiceOnStatusChange
{
@future(callout=true)
public static void callWebService(Set<Id> resultIds)
{
try
{
List<PCS_Detail__c> pcsDetail = [Select Name__r.Id,Name__r.Name,Name__r.Breed__c,Name__r.Species__c,Name__r.Gender__c From PCS_Detail__c Where Id IN :resultIds];
NewPetInformation.PackageServiceSoap obj = new NewPetInformation.PackageServiceSoap();
obj.UpdateDatabase(pcsDetail);
}
catch(System.AsyncException e)
{
System.debug('Exception' +e);
}
}

.NET web method,
[WebMethod]
public void UpdateDatabase(List<PCSDetail> values)
{
SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
SqlCommand comm = new SqlCommand();
comm.CommandText = "Insert into PetInformation(Id,Name,Breed,Species,Gender) values(@p0,@p1,@p2,@p3,@p4)"; comm.Parameters.AddWithValue("@p0", values[0].Id); comm.Parameters.AddWithValue("@p1", values[0].Name); comm.Parameters.AddWithValue("@p2", values[0].Breed); comm.Parameters.AddWithValue("@p3", values[0].Species); comm.Parameters.AddWithValue("@p4", values[0].Gender);
comm.Connection = constr;
comm.ExecuteNonQuery();
}

Model,
public class PCSDetail
{
public string Id { get; set; }
public string Name { get; set; }
public string Breed { get; set; }
public string Species { get; set; }
public string Gender { get; set; }
}

After generating WSDL and parsed the WSDL into apex classes when i save the apex class which calls the web service, i get the error saying 

Method does not exist or incorrect signature: [NewPetInformation.PackageServiceSoap].UpdateDatabase(List). How to solve this.
http://salesforce.stackexchange.com/questions/115453/web-service-callout-from-salesforce-to-net-using-soap
  • March 25, 2016
  • Like
  • 0
When i update a picklist value from 'Requested' to 'Approved' then it should invoke a trigger which in turn calls an external web service (.net web application) and pass those data of the updated record along with it and those records should be received by the .net application and saved on sql server database. I am totally new to Salesforce and Web service.

Trigger,
trigger AdoDetailTrigger on PCS_Detail__c (after update)
{
List<PCS_Detail__c> pcsDetail = [Select Id,Tracking_Details__c From PCS_Detail__c Where Id IN :Trigger.new]; if(pcsDetail[0].Tracking_Details__c == 'Approved')
{
Set<Id> resultIds = (new Map<Id,SObject>(pcsDetail)).keySet();
InvokeWebServiceOnStatusChange.callWebService(resultIds);
}
}

Apex class future callout,
public class InvokeWebServiceOnStatusChange
{
@future(callout=true)
public static void callWebService(Set<Id> resultIds)
{
try
{
List<PCS_Detail__c> pcsDetail = [Select Name__r.Id,Name__r.Name,Name__r.Breed__c,Name__r.Species__c,Name__r.Gender__c From PCS_Detail__c Where Id IN :resultIds];
NewPetInformation.PackageServiceSoap obj = new NewPetInformation.PackageServiceSoap();
obj.UpdateDatabase(pcsDetail);
}
catch(System.AsyncException e)
{
System.debug('Exception' +e);
}
}

.NET web method,
[WebMethod]
public void UpdateDatabase(List<PCSDetail> values)
{
SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
SqlCommand comm = new SqlCommand();
comm.CommandText = "Insert into PetInformation(Id,Name,Breed,Species,Gender) values(@p0,@p1,@p2,@p3,@p4)"; comm.Parameters.AddWithValue("@p0", values[0].Id); comm.Parameters.AddWithValue("@p1", values[0].Name); comm.Parameters.AddWithValue("@p2", values[0].Breed); comm.Parameters.AddWithValue("@p3", values[0].Species); comm.Parameters.AddWithValue("@p4", values[0].Gender);
comm.Connection = constr;
comm.ExecuteNonQuery();
}

Model,
public class PCSDetail
{
public string Id { get; set; }
public string Name { get; set; }
public string Breed { get; set; }
public string Species { get; set; }
public string Gender { get; set; }
}

After generating WSDL and parsed the WSDL into apex classes when i save the apex class which calls the web service, i get the error saying 

Method does not exist or incorrect signature: [NewPetInformation.PackageServiceSoap].UpdateDatabase(List). How to solve this.
http://salesforce.stackexchange.com/questions/115453/web-service-callout-from-salesforce-to-net-using-soap
  • March 25, 2016
  • Like
  • 0