Friday, March 8, 2013

Testing Google prettyPrint...

This is a test page with some code on it!

Here is the code:


function myFunc(cb){ if($(cb).is(':checked')){ //alert("checked!!!"); $('input[name$="oliCheck"]').prop("checked",true); }else{ $('input[name$="oliCheck"]').prop("checked",false); } //console.log(tName); }

Thursday, March 7, 2013

Generating a WSDL from Salesforce and then generating Java libraries (JAR)....

The first thing you have to do is make sure your Java (JDK) development environment is all set up.  I have a short guide to doing this here: http://anotherforceblog.blogspot.com/2013/03/setting-up-jdk-se616-and-eclipse-for.html

Once you are all good to go and can at the very lest, type java at the command prompt without getting an error follow these general steps:

The First thing you will need to go do is to get the Force.com Web Service Connector (WSC).  You can find it here:

http://code.google.com/p/sfdc-wsc/downloads/list

I will be using wc-23.jar for this.

Save this file into your "lib" folder, ie:

C:\Program Files (x86)\Java\jdk1.6.0_43\lib

First things first.  I have had issues downloading WSDL's using Chrome.  FireFox and IE both seem to get them correctly.  I'll go through the steps using Firefox as any little thing seemed to throw errors for me while building the libraries.

First log into Salesforce and then goto "Your Name" > Setup > Develop > API

Select the WSDL you want to generate by clicking on the link under the WSDL type, I am generating an Enterprise WSDL for this.

The next screen will list all of the packages installed in your org, you can review the verson settings for each if there are any.

When you are ready, click the "Generate" button.

You'll be redirected to wsdl.jsp page which is an XML document.

Now Save this, in Firefox : Save Page As > Now Firefox is going to have a name already populated in the save field, delete it and name it on your own.  If you save it or rename it with the.wsdl extension FF put on it, it will save as a .wsdl.xml file and will cause the wsc program to fail (no such file found etc..)

Select your save location and click save

Once your file has been saved open up a CMD prompt and navigate to the folder that has your .wsdl file in it.  The easiest way to do this is to navigate to the location in explorer and then copy the address out of the address bar and then go into your cmd window, type CD <space> and then right click and select paste and hit enter



Now that you are in the directory, you will need to run the following (similar different version/type) command to generate the library.jar:

java -classpath "C:\Program Files (x86)\Java\jdk1.6.0_43\lib\wc-23.jar;C:\Program Files (x86)\Java\jdk1.6.0_43\lib\tools.jar" com.sforce.ws.tools.wsdlc enterprise.jar entlib.jar

The breakdown for this is: java -classpath "<directory with wsc-2*.jar>;<directory with jdk tools.jar>" com.sforce.ws.tools.wsdlc <wsdl filename> <jar output name>



If everything was in the right place and all the files were correct you should have a new jar file named whatever you named it in the directory with your WSDL file.




Setting up JDK SE6(1.6) and Eclipse for SalesForce webservice development...



1: install jdk 1.6
Check to see which version of Java you have installed (ie 32 or 64 bit)  you may need to uninstall and reinstall the Java RTE (by installing the JDK): (Control Panel > Java (32/64 bit)
Download from here:

2: Next, download and install Eclipse Juno IDE for Java EE Dev (32 or 64 bit, depends on which RTE/JDK you have installed)

3:  Before you can compile and run Java code using “-classpath” you will need to add the path to your system path (this will resolve any java not recognized as an internal or external command errors from the command prompt):
Right click Computer : Advanced System Settings : Environment variables >  System Variables > Path :
Make sure you have the lib and bin paths (this will be dependent on how you have java installed/version etc.) added to this with a semi colon separating them ie:
Example:  C:\Program Files (x86)\Java\jdk1.6.0_43\lib;C:\Program Files (x86)\Java\jdk1.6.0_43\bin;

4:  After adding that to the Path value and clicking “OK”, you may want to add a new variable: CLASSPATH
This will again be the same thing that you just added to the Path variable. IE:
Example: C:\Program Files (x86)\Java\jdk1.6.0_43\lib;C:\Program Files (x86)\Java\jdk1.6.0_43\bin;

Make sure to click OK at each window so your changes take effect!!

4b:  You can test to see if this worked by opening a command prompt and typing, “java” (without the quotes), it should return a usage menu.

5:  You will probably also want to download SOAPUI as well.  You can get it here:
I went with the eclipse plug in.
You should be ready to go with Java development now (ie web services and such)