In this and following blogposts I would like to share my experience with integrating SalesForce with a fictive system via MSMQ (fictive system could be ERP, package application, service, ect). Integration is facilitated by BizTalk Server 2009 running on one of my VM machines (hosted by Hyper-V, see BizTalk Virtual Machines with Windows 2008 R2 Hyper V).
SalesForce is a leading CRM software solution that runs in the cloud and can be viewed as software as a service (SaaS). SalesForce itself states it is a leader in CRM (true if you consider their offering as off-premise software) and platform as a service. Latter sounds optimistic as there are some similarities with Microsoft Azure, which is also viewed as platform as a service with richer set of capabilities and a lot more flexibility. SalesForce is more targeted on CRM and you can build applications around it that can be hosted in the cloud or develop services, which I did and I am not the only one. I was inspired by Richard Seroter’s post and the fact that I had to do a POC integrating SalesForce (CRM) with Navision (Finance).
Prerequisites for anyone who would like to integrate with SalesForce is to setup an account with SalesForce to have an development environment (Sandbox) available to build.
Second is having an BizTalk development environment (VS 2008, SQL Server 2008) with connection to internet. If you filled in the details, accept agreement and submit, you will receive an email in couple of minutes you can use to login. After login you need to one time change the password.
Once that is done you can start setting some things in SalesForce listed down below:
1. Adding an account
Note: language here is Dutch as it is localized.
2. Save and add some detail to account
3. Now I can go to APEX classes and develop some code
Notice that if you click save after developing some code, it will compile and tell you if there is an error. If syntax is correct and code compiles then you will something similar as below.
To have access to this created web service you need to have a security token and your credentials. As stated on their site they mention the following:
When accessing salesforce.com from outside of your company’s trusted networks, you must add a security token to your password to log in to the API or a desktop client such as Connect for Outlook, Connect Offline, Connect for Office, Connect for Lotus Notes, or the Data Loader. For security reasons, your security token is delivered to the email address associated with your account. To reset and send your security token, click the button below.
You basically have to reset your security token, because it will not be provided when you create an account with SalesForce. If you provide security token you will receive a INVALID_LOGIN error.
Security token is necessary to setup session and reuse it (see also code Richard Seroter created for his solution).
Another thing you need to do is to generate Enterprise WSDL. Each SalesForce.com sandbox (like mine) has its own WSDL file (enterprise.wsdl). To access the Force.com Web service, you need this WSDL file. It defines the Web service that is available to you. Your development platform uses this WSDL to generate an API to access the Force.com Web service it defines. You can either obtain the WSDL file from your organization’s Salesforce.com administrator or you can generate it yourself if you have access to the WSDL download page in the Salesforce.com user interface. Click Setup Develop API to display the WSDL download page. For more info see SalesForce API Quickstart.
You can save the WSDL to file.
I created an empty solution called SalesForce.Integration.POC and a created helper class called BTSSFHelper, through creating C# class library (SalesForce.Integration.POC.BTSSFHelper). Next is to add service reference to enterprise.wsdl. I tried through service referenc, but it somehow does not compile:
Error = “Error 101 The namespace ‘SalesForce.Integration.POC.BTSSFHelper.SvcSFRef’ already contains a definition for ‘ExceptionCode’ C:ProjectsSalesForce.Integration.POCSalesForce.Integration.POC.BTSSFHelperService ReferencesSvcSFRefReference.cs 808 17 SalesForce.Integration.POC.BTSSFHelper”
I did a workaround by deleting service reference and add web service reference (that is the old way or at least VS 2005 way) through service reference –> advanced –> Add Web Reference.
If I build now there is no problem. Next step was to sign the helperclass with a strong name and rebuild. Next is to create a new BizTalk Project called SalesForce.Integration.POC.Solution to add to the solution. In this project I like to consume the web service I build in SalesForce. I need wsdl from my service, so in SalesForce I navigate to Apex classes and generate WSDL.
WSDL like enterprise one I save to file. I then go to Add Generated Items –> Consume WebService and walk through the wizard (Metadata Files –> WSDL from file –> Add WSDL –> Import).
Now I all set to consume my SalesForce web service within an orchestration. This is will be discussed in my next post Part II together with interaction with MSMQ. I hope by now some of steps are clear to setup an environment in SalesForce to create a web service and necessary security.