I saw people in industry are really crazy to learn Integration .Real thing is that integration is not a rocket science kind of thing .
In my view a developer who is logically good he will definitely good in integration .
Lets discuss about integration/web service .
Web service basically are of two types :
1.SOAP(Simple Object Access Protocol)
2.REST (Representational State Transfer)
I know every body have at least idea about above two types of we service.
Again in each we can have Inbound and Outbound web service .
Lets discuss what is inbound and outbound web service .
When we are writing a service for other and for us it is Inbound and for Other it is outbound web service .
Same way when we are consuming other's service then for us it is outbound and for them it is inbound web service .
I think now we are clear, what is inbound and out bound web service .
Lets discus as a sales force developer how we can write inbound web service for others .
Inbound Web Service Using SOAP :
Here we will learn how to write a sample web service using SOAP and how we can test ,also how we can write test class for this .
To write a web service we need to write a apex class .
Assume that we have written a web service to get account name based on one external Id .
So while calling this web service client needs to pass theexternal Id and in response it will return the name ,we can return other things as per our requirement .
global class AccountService{
webservice static String getAccountName(String extid){
if(extid != null){
String accName=[SELECT Id,Name FROM Account WHERE APINameExtid =: extid LIMIT 1].Name;
return accName;
}
return null;
}
}
Replace APINameExtid with your external id Api name of field created in Account .
Example 2 :
In my view a developer who is logically good he will definitely good in integration .
Lets discuss about integration/web service .
Web service basically are of two types :
1.SOAP(Simple Object Access Protocol)
2.REST (Representational State Transfer)
I know every body have at least idea about above two types of we service.
Again in each we can have Inbound and Outbound web service .
Lets discuss what is inbound and outbound web service .
When we are writing a service for other and for us it is Inbound and for Other it is outbound web service .
Same way when we are consuming other's service then for us it is outbound and for them it is inbound web service .
I think now we are clear, what is inbound and out bound web service .
Lets discus as a sales force developer how we can write inbound web service for others .
Inbound Web Service Using SOAP :
Here we will learn how to write a sample web service using SOAP and how we can test ,also how we can write test class for this .
To write a web service we need to write a apex class .
- Class should be global access specified .
- Methods should be start with web service key word .
- Any method that uses the Web Service keyword should static .
- Return type should not Map,Set,Pattern Object, Matcher Object,Exception Object .
- We cannot deprecate webService methods or variables in managed package
Assume that we have written a web service to get account name based on one external Id .
So while calling this web service client needs to pass theexternal Id and in response it will return the name ,we can return other things as per our requirement .
global class AccountService{
webservice static String getAccountName(String extid){
if(extid != null){
String accName=[SELECT Id,Name FROM Account WHERE APINameExtid =: extid LIMIT 1].Name;
return accName;
}
return null;
}
}
Replace APINameExtid with your external id Api name of field created in Account .
Example 2 :