SlideShare a Scribd company logo
By Forcetree.com




   Copyright Forcetree.com
 It is assumed that you have very little programming
  knowledge in JAVA and APEX for salesforce.com, or
  the other SOFTWARES used in the process.
 This guide is intended to give you a step by step
  procedure to write a simple JAVA program and connect
  to Salesforce.com.
 This guide should approximately take 1 to 2 hours or
  less to complete.



                        Copyright Forcetree.com
 Go to




          Copyright Forcetree.com
Copyright Forcetree.com
Copyright Forcetree.com
Copyright Forcetree.com
Copyright Forcetree.com
 Install the Force.com plugin for ECLIPSE (optional)
 Even though it’s optional, it’s highly recommended
 that you do this step. Your future developments would
 be dependent on this plugin




                        Copyright Forcetree.com
 Follow the instructions as listed in the below URL




                        Copyright Forcetree.com
Courtesy :




Download the latest version of Apache Axis
from




                     Copyright Forcetree.com
Copyright Forcetree.com
Copyright Forcetree.com
 Download the ZIP file
 Extract the ZIP file and save as C:axis-1_4
 Download the following files
 Activation.jar


 Mail.jar


 Xmlsec.jar


   Extract these 3 supporting libraries and copy
    the .jar files to the lib folder inside the WEB-
    INF folder of your Axis installation folder. (image
    shown in next slide)


                           Copyright Forcetree.com
Copyright Forcetree.com
 Copy “activation.jar” and “mail.jar” and paste it into
  the location shown below. Also, verify that the
  contents of the location shown below is the same for
  you.




                         Copyright Forcetree.com
 Copy the axis folder inside the webapps folder of the
 Axis distribution folder, to your Apache
 Tomcat webapps folder. (as in the images shown
 below)




                        Copyright Forcetree.com
Copyright Forcetree.com
 Set the following path variables. Refer Slide 6 if you are
  unsure how to set path variables.




                         Copyright Forcetree.com
 AXIS_HOME = C:axis-1_4
 AXIS_LIB = %AXIS_HOME%lib
 AXISCLASSPATH =
  %AXIS_LIB%axis.jar;%AXIS_LIB%commons-discovery-
  0.2.jar;%AXIS_LIB%commons-logging-
  1.0.4.jar;%AXIS_LIB%jaxrpc.jar;%AXIS_LIB%saaj.jar;%A
  XIS_LIB%log4j-1.2.8.jar;%AXIS_LIB%xml-
  apis.jar;%AXIS_LIB%xercesImpl.jar;%AXIS_LIB%wsdl4j-
  1.5.1.jar
 CLASSPATH = C:Program
  FilesJavajdk1.7.0_02bin;C:Program
  FilesJavajdk1.7.0_02jrebin;C:axis-1_4;C:axis-
  1_4libwsdl4j-1.5.1.jar;C:axis-1_4libmail.jar;C:axis-
  1_4libactivation.jar;C:axis-1_4libsaaj.jar;C:axis-
  1_4liblog4j-1.2.8.jar;C:axis-1_4libjaxrpc.jar;C:axis-
  1_4libcommons-logging-1.0.4.jar;C:axis-
  1_4libcommons-discovery-0.2.jar;C:axis-
  1_4libaxis.jar;C:axis-1_4libaxis-ant.jar
                          Copyright Forcetree.com
 Start your Apache Tomcat or restart it if you've got it running.
 Access http://localhost:8080/axis. If you see the result like below
  this, it means you have installed Apache Axis successfully. You can also
  click the Validation link to check if your Axis' installation
  configuration is fine.




                                Copyright Forcetree.com
The steps in this video are explained in the slides below.
Youtube URL: http://www.youtube.com/watch?v=tK2CiLb5vgc

Go to the next slide to play the video




                                    Copyright Forcetree.com
 Download the “Enterprise WSDL” as shown in the video.
 Create a folder on your desktop called “demo2”. Create a folder inside
  “demo2” called “Downloads”. Paste the “enterprise.wsdl.xml” file into
  the “Downloads” folder.




                                Copyright Forcetree.com
 Go to the command prompt and execute the following command.
 C:Users436321Desktopdemo2>java org.apache.axis.wsdl.WSDL2Java -a
  c:Users436321desktopdemo2downloadsenterprise.wsdl.xml




                               Copyright Forcetree.com
 After you execute the command, a new folder called
  “com” would be created inside your “demo2” folder.




 Start “eclipse”.
 Follow the steps outlined in the video in the next slide.
  The JAVA program source code is also provided after
  the video.

                         Copyright Forcetree.com
Go to the next slide to play the video

Youtube URL: http://www.youtube.com/watch?v=gAx0XVgne3w




                                 Copyright Forcetree.com
   import com.sforce.soap.enterprise.LoginResult;
   import com.sforce.soap.enterprise.QueryResult;
   import com.sforce.soap.enterprise.SessionHeader;
   import com.sforce.soap.enterprise.SforceServiceLocator;
   import com.sforce.soap.enterprise.SoapBindingStub;
   import com.sforce.soap.enterprise.sobject.Contact;



   public class RunDemo {
   private static final String USERNAME = “provide username here";
   private static final String TOKEN = “provide token here";
   private static final String PASSWORD = “provide password here" + TOKEN;
   private SoapBindingStub binding;
   public static void main(String[] args) {
              RunDemo d = new RunDemo();
              try {
                             d.login();
              } catch (Exception e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
              }
              try {
                             d.search();
              } catch (Exception e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
              }
   }                                                Copyright Forcetree.com
   private void login() throws Exception{
             binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
             LoginResult loginResult = binding.login(USERNAME, PASSWORD);

             binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
             SessionHeader sh = new SessionHeader();
             sh.setSessionId(loginResult.getSessionId());
             binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader",sh);

   }
   private void search() throws Exception{
             QueryResult qr=binding.query("Select FirstName, LastName from Contact");
             if (qr.getSize() > 0)
                             for (int i=0; i<qr.getSize(); i++){
                                             Contact c = (Contact) qr.getRecords(i);
                                             System.err.println(c.getFirstName() +" "+ c.getLastName() );

                           }

   }

   }




                                                      Copyright Forcetree.com
Like us at: Forcetree.com - Facebook page
Visit us at: Forcetree.com
                                 Copyright Forcetree.com

More Related Content

PDF
WebDriver Waits
PDF
Implicit and Explicit waits in Selenium WebDriwer, how to.
PDF
Automation puzzlers
PDF
Alfresco study37 alfresco_ng2_components
DOCX
My java file
PPTX
Python from zero to hero (Twitter Explorer)
PPTX
How to Install Odoo 11 on Ubuntu 16.04?
PDF
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
WebDriver Waits
Implicit and Explicit waits in Selenium WebDriwer, how to.
Automation puzzlers
Alfresco study37 alfresco_ng2_components
My java file
Python from zero to hero (Twitter Explorer)
How to Install Odoo 11 on Ubuntu 16.04?
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm

What's hot (14)

PDF
Sead 29 09 2006 Usabilidade Com Ajax
PDF
Error xaction etl_ktr
PDF
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
PDF
Flask SQLAlchemy
PPTX
Retrofit 2 - O que devemos saber
PDF
Crushing React bugs with Jest and Enzyme
PDF
"Less Painful iOS Development" by Samuel Edwin (Tokopedia)
PPTX
AssertJ quick introduction
PDF
Supporting Debian machines for friends and family
PDF
Easy logins for Ruby web applications
PDF
Stacki: Remove Commands
PDF
Agile Android
PDF
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
PDF
Flask Basics
Sead 29 09 2006 Usabilidade Com Ajax
Error xaction etl_ktr
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Flask SQLAlchemy
Retrofit 2 - O que devemos saber
Crushing React bugs with Jest and Enzyme
"Less Painful iOS Development" by Samuel Edwin (Tokopedia)
AssertJ quick introduction
Supporting Debian machines for friends and family
Easy logins for Ruby web applications
Stacki: Remove Commands
Agile Android
DevOps Fest 2020. Philipp Krenn. Scale Your Auditing Events
Flask Basics
Ad

Similar to Forcetree.com writing a java program to connect to sfdc (20)

PPTX
SFDC Inbound Integrations
PPTX
Developing SOAP Web Services using Java
PDF
Application Services On The Web Sales Forcecom
PDF
Get Java EE Development with Eclipse - Second Edition Ram Kulkarni free all c...
KEY
Enterprise Java Web Application Frameworks Sample Stack Implementation
DOCX
RaviThapa
PPTX
Writing simple web services in java using eclipse editor
PPT
Java overview the piramide of success
PPT
Using Java to implement SOAP Web Services: JAX-WS
PDF
Jakarta EE 10 - Simplicity for Modern and Lighweight Cloud
PDF
Jakarta EE 10 - Simplicity for Modern and Lighweight Cloud Applications
PDF
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
PPT
Intro to AppExchange - Building Composite Apps
ODP
The xsp starter kit
PDF
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
PDF
Jlook open api server platform
ODP
Java EE and Glassfish
PPTX
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
PDF
J2EE Developer s Handbook Paul J. Perrone
PDF
Building towards a Composite API Framework in Salesforce
SFDC Inbound Integrations
Developing SOAP Web Services using Java
Application Services On The Web Sales Forcecom
Get Java EE Development with Eclipse - Second Edition Ram Kulkarni free all c...
Enterprise Java Web Application Frameworks Sample Stack Implementation
RaviThapa
Writing simple web services in java using eclipse editor
Java overview the piramide of success
Using Java to implement SOAP Web Services: JAX-WS
Jakarta EE 10 - Simplicity for Modern and Lighweight Cloud
Jakarta EE 10 - Simplicity for Modern and Lighweight Cloud Applications
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Intro to AppExchange - Building Composite Apps
The xsp starter kit
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Jlook open api server platform
Java EE and Glassfish
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
J2EE Developer s Handbook Paul J. Perrone
Building towards a Composite API Framework in Salesforce
Ad

Recently uploaded (20)

PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Presentation on HIE in infants and its manifestations
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Cell Types and Its function , kingdom of life
A systematic review of self-coping strategies used by university students to ...
GDM (1) (1).pptx small presentation for students
Final Presentation General Medicine 03-08-2024.pptx
O7-L3 Supply Chain Operations - ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
2.FourierTransform-ShortQuestionswithAnswers.pdf
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
FourierSeries-QuestionsWithAnswers(Part-A).pdf
human mycosis Human fungal infections are called human mycosis..pptx
Anesthesia in Laparoscopic Surgery in India
Presentation on HIE in infants and its manifestations
STATICS OF THE RIGID BODIES Hibbelers.pdf
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Cell Types and Its function , kingdom of life

Forcetree.com writing a java program to connect to sfdc

  • 1. By Forcetree.com Copyright Forcetree.com
  • 2.  It is assumed that you have very little programming knowledge in JAVA and APEX for salesforce.com, or the other SOFTWARES used in the process.  This guide is intended to give you a step by step procedure to write a simple JAVA program and connect to Salesforce.com.  This guide should approximately take 1 to 2 hours or less to complete. Copyright Forcetree.com
  • 3.  Go to Copyright Forcetree.com
  • 8.  Install the Force.com plugin for ECLIPSE (optional)  Even though it’s optional, it’s highly recommended that you do this step. Your future developments would be dependent on this plugin Copyright Forcetree.com
  • 9.  Follow the instructions as listed in the below URL Copyright Forcetree.com
  • 10. Courtesy : Download the latest version of Apache Axis from Copyright Forcetree.com
  • 13.  Download the ZIP file  Extract the ZIP file and save as C:axis-1_4  Download the following files  Activation.jar  Mail.jar  Xmlsec.jar  Extract these 3 supporting libraries and copy the .jar files to the lib folder inside the WEB- INF folder of your Axis installation folder. (image shown in next slide) Copyright Forcetree.com
  • 15.  Copy “activation.jar” and “mail.jar” and paste it into the location shown below. Also, verify that the contents of the location shown below is the same for you. Copyright Forcetree.com
  • 16.  Copy the axis folder inside the webapps folder of the Axis distribution folder, to your Apache Tomcat webapps folder. (as in the images shown below) Copyright Forcetree.com
  • 18.  Set the following path variables. Refer Slide 6 if you are unsure how to set path variables. Copyright Forcetree.com
  • 19.  AXIS_HOME = C:axis-1_4  AXIS_LIB = %AXIS_HOME%lib  AXISCLASSPATH = %AXIS_LIB%axis.jar;%AXIS_LIB%commons-discovery- 0.2.jar;%AXIS_LIB%commons-logging- 1.0.4.jar;%AXIS_LIB%jaxrpc.jar;%AXIS_LIB%saaj.jar;%A XIS_LIB%log4j-1.2.8.jar;%AXIS_LIB%xml- apis.jar;%AXIS_LIB%xercesImpl.jar;%AXIS_LIB%wsdl4j- 1.5.1.jar  CLASSPATH = C:Program FilesJavajdk1.7.0_02bin;C:Program FilesJavajdk1.7.0_02jrebin;C:axis-1_4;C:axis- 1_4libwsdl4j-1.5.1.jar;C:axis-1_4libmail.jar;C:axis- 1_4libactivation.jar;C:axis-1_4libsaaj.jar;C:axis- 1_4liblog4j-1.2.8.jar;C:axis-1_4libjaxrpc.jar;C:axis- 1_4libcommons-logging-1.0.4.jar;C:axis- 1_4libcommons-discovery-0.2.jar;C:axis- 1_4libaxis.jar;C:axis-1_4libaxis-ant.jar Copyright Forcetree.com
  • 20.  Start your Apache Tomcat or restart it if you've got it running.  Access http://localhost:8080/axis. If you see the result like below this, it means you have installed Apache Axis successfully. You can also click the Validation link to check if your Axis' installation configuration is fine. Copyright Forcetree.com
  • 21. The steps in this video are explained in the slides below. Youtube URL: http://www.youtube.com/watch?v=tK2CiLb5vgc Go to the next slide to play the video Copyright Forcetree.com
  • 22.  Download the “Enterprise WSDL” as shown in the video.  Create a folder on your desktop called “demo2”. Create a folder inside “demo2” called “Downloads”. Paste the “enterprise.wsdl.xml” file into the “Downloads” folder. Copyright Forcetree.com
  • 23.  Go to the command prompt and execute the following command.  C:Users436321Desktopdemo2>java org.apache.axis.wsdl.WSDL2Java -a c:Users436321desktopdemo2downloadsenterprise.wsdl.xml Copyright Forcetree.com
  • 24.  After you execute the command, a new folder called “com” would be created inside your “demo2” folder.  Start “eclipse”.  Follow the steps outlined in the video in the next slide. The JAVA program source code is also provided after the video. Copyright Forcetree.com
  • 25. Go to the next slide to play the video Youtube URL: http://www.youtube.com/watch?v=gAx0XVgne3w Copyright Forcetree.com
  • 26. import com.sforce.soap.enterprise.LoginResult;  import com.sforce.soap.enterprise.QueryResult;  import com.sforce.soap.enterprise.SessionHeader;  import com.sforce.soap.enterprise.SforceServiceLocator;  import com.sforce.soap.enterprise.SoapBindingStub;  import com.sforce.soap.enterprise.sobject.Contact;  public class RunDemo {  private static final String USERNAME = “provide username here";  private static final String TOKEN = “provide token here";  private static final String PASSWORD = “provide password here" + TOKEN;  private SoapBindingStub binding;  public static void main(String[] args) {  RunDemo d = new RunDemo();  try {  d.login();  } catch (Exception e) {  // TODO Auto-generated catch block  e.printStackTrace();  }  try {  d.search();  } catch (Exception e) {  // TODO Auto-generated catch block  e.printStackTrace();  }  } Copyright Forcetree.com
  • 27. private void login() throws Exception{  binding = (SoapBindingStub) new SforceServiceLocator().getSoap();  LoginResult loginResult = binding.login(USERNAME, PASSWORD);   binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());  SessionHeader sh = new SessionHeader();  sh.setSessionId(loginResult.getSessionId());  binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(),"SessionHeader",sh);   }  private void search() throws Exception{  QueryResult qr=binding.query("Select FirstName, LastName from Contact");  if (qr.getSize() > 0)  for (int i=0; i<qr.getSize(); i++){  Contact c = (Contact) qr.getRecords(i);  System.err.println(c.getFirstName() +" "+ c.getLastName() );   }   }  } Copyright Forcetree.com
  • 28. Like us at: Forcetree.com - Facebook page Visit us at: Forcetree.com Copyright Forcetree.com