You need to sign in to do that
Don't have an account?
dragan loncar
Web service callout using SOAP
HI
What i doing wrong PLEASE HELP
I am using SOAP and want to call web service from salesforces to update table using WebServiceCallout
i create WEB SERVICE file in visual studio
namespace WebApplication79
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://step23.ca")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public void updatedatabase()
{
string constr = ConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand comm = new SqlCommand();
comm.CommandText = "Insert into Branch(branch) values('dragan')";
con.Open();
comm.Connection = con;
comm.ExecuteNonQuery();
con.Close();
// return "Hello World";
}
}
}
after that i generate apex class from wsdl
//Generated by wsdl2apex
public class step23Ca {
public class updatedatabaseResponse_element {
private String[] apex_schema_type_info = new String[]{'http://step23.ca','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class updatedatabase_element {
private String[] apex_schema_type_info = new String[]{'http://step23.ca','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class WebService1Soap {
public String endpoint_x = 'http://184.154.149.230/WebService1.asmx';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://step23.ca', 'step23Ca'};
public void updatedatabase() {
step23Ca.updatedatabase_element request_x = new step23Ca.updatedatabase_element();
step23Ca.updatedatabaseResponse_element response_x;
Map<String, step23Ca.updatedatabaseResponse_element> response_map_x = new Map<String, step23Ca.updatedatabaseResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://step23.ca/updatedatabase',
'http://step23.ca',
'updatedatabase',
'http://step23.ca',
'updatedatabaseResponse',
'step23Ca.updatedatabaseResponse_element'}
);
response_x = response_map_x.get('response_x');
}
}
}
and I cretae trigger
trigger AdoDetailTrigger on members__c (before update,after update) {
List<members__c> pcsDetail = [Select Id,firstname__c From members__c Where Id IN :Trigger.new];
//Set<Id> resultIds = (new Map<Id,SObject>(pcsDetail)).keySet();
InvokeWebServiceOnAdoptionStatusChange.callWebService();
}
and call class to call web service
public class InvokeWebServiceOnAdoptionStatusChange {
@future(callout=true)
public static void callWebService() {
try {
step23Ca.WebService1Soap x = new step23Ca.WebService1Soap();
x.updatedatabase();
}
catch(System.AsyncException e) {
System.debug('Exception' +e);
}
}
}
WHEN I RUNNING CODE NOTHING HAPPENED IN DATABASE TO UPDATE RECORD
what i am doing wrong
PLEASE HELP please
regards
What i doing wrong PLEASE HELP
I am using SOAP and want to call web service from salesforces to update table using WebServiceCallout
i create WEB SERVICE file in visual studio
namespace WebApplication79
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://step23.ca")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public void updatedatabase()
{
string constr = ConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand comm = new SqlCommand();
comm.CommandText = "Insert into Branch(branch) values('dragan')";
con.Open();
comm.Connection = con;
comm.ExecuteNonQuery();
con.Close();
// return "Hello World";
}
}
}
after that i generate apex class from wsdl
//Generated by wsdl2apex
public class step23Ca {
public class updatedatabaseResponse_element {
private String[] apex_schema_type_info = new String[]{'http://step23.ca','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class updatedatabase_element {
private String[] apex_schema_type_info = new String[]{'http://step23.ca','true','false'};
private String[] field_order_type_info = new String[]{};
}
public class WebService1Soap {
public String endpoint_x = 'http://184.154.149.230/WebService1.asmx';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://step23.ca', 'step23Ca'};
public void updatedatabase() {
step23Ca.updatedatabase_element request_x = new step23Ca.updatedatabase_element();
step23Ca.updatedatabaseResponse_element response_x;
Map<String, step23Ca.updatedatabaseResponse_element> response_map_x = new Map<String, step23Ca.updatedatabaseResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://step23.ca/updatedatabase',
'http://step23.ca',
'updatedatabase',
'http://step23.ca',
'updatedatabaseResponse',
'step23Ca.updatedatabaseResponse_element'}
);
response_x = response_map_x.get('response_x');
}
}
}
and I cretae trigger
trigger AdoDetailTrigger on members__c (before update,after update) {
List<members__c> pcsDetail = [Select Id,firstname__c From members__c Where Id IN :Trigger.new];
//Set<Id> resultIds = (new Map<Id,SObject>(pcsDetail)).keySet();
InvokeWebServiceOnAdoptionStatusChange.callWebService();
}
and call class to call web service
public class InvokeWebServiceOnAdoptionStatusChange {
@future(callout=true)
public static void callWebService() {
try {
step23Ca.WebService1Soap x = new step23Ca.WebService1Soap();
x.updatedatabase();
}
catch(System.AsyncException e) {
System.debug('Exception' +e);
}
}
}
WHEN I RUNNING CODE NOTHING HAPPENED IN DATABASE TO UPDATE RECORD
what i am doing wrong
PLEASE HELP please
regards