Speaking at Dreamforce 2012 in September

Dreamforce 2012Last week I learned that two of my proposed topics were accepted for presentations at Dreamforce 2012 as breakout sessions on the Developer Track. I am honored to have been chosen and excited about helping others improve their development practices and techniques.

My first topic is Enterprise/Team Development on the Force.com Platform

Have you tried working with multiple developers in a single Sandbox or Development Org? Did you lose work or have to wait for someone to complete their tests before saving your changes? Are your cloud projects taking longer than you want them because you are limited to a single developer and they can only write so much code per day?

In this session, you’ll learn strategies that will help your teams increase their productivity by helping them coordinate more effectively and leverage powerful practices to complete your projects faster. A few of the topics we will dive into include:

What to think about before you write any code
What type of org is right for your team?
Source Code Control Strategies and its importance
Unit Testing Strategies for dealing with data and callouts
Deployment Strategies

This is a pragmatic session that will help you and your teams become more productive. Bring your team members, your challenges and your questions.

Dreamforce
My second topic is Cloud Jumping: Leveraging Dynamic Capabilities of Heroku from Force.com

One of our clients had a situation where formulas were too limiting for their needs and implementing custom objects to express criteria was too cumbersome, error prone and time consuming. What they really needed was to be able to write complex formulas in a dynamic language.

Writing our own formula language and the code to parse it within Apex was something we considered but quickly decided that it would take too much time due to the complexity involved. A tight deadline and knowing that writing a custom formula engine is not trivial forced us to invent a different solution, one that is a unique combination of dynamically generated Javascript on Force.com that is executed on Heroku.

Why reinvent or develop a new formula language when one already exists?

In this session, you will learn how we implemented this solution that enabled us to jump between Force.com and Heroku to leverage the strengths of both platforms and provide a timely solution for our customer. Come prepared to dive into the cloud and think about ways that you could leverage something similar in your own companies.

Dreamforce 2012 runs from September 18th – 21st in San Francisco, California. If you are or will be attending, I invite you to attend one or both of my sessions.

Posted in Dreamforce, Heroku, PaaS, Salesforce.com | Leave a comment

Force.com: Resolving the Destination URL not reset exception

Salesforce provides a number of methods for integrating Java and/or .NET applications using SOAP APIs. Depending on the type of application you will be writing will determine which WSDL(s) you will need to generate and consume. These WSDLs are located in Your Name | Setup | Develop | API.

Earlier today I was writing a Java client to connect via the Web Services API through the Enterprise WSDL. Using the Force.com Web Services Connector (WSC), I generated the stub code from the wsdl and included the jar files in my project. These details can be found by clicking the link above.

Connecting to Salesforce seemed pretty straightforward. In my case, I needed to use the Connector.newConnection() method. So I did this:

package com.rickross;

import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

public class BrokenDemo 
{
	public static void main(String[] args) 
		throws ConnectionException 
	{
		System.out.println("Starting Broken Demo");
		ConnectorConfig config = new ConnectorConfig();
		config.setManualLogin(true);	
		EnterpriseConnection conn = 
			Connector.newConnection(config);
		LoginResult result = 
			conn.login("username", "pwd+token");
		if (!result.getPasswordExpired())
		{
			Account account = new Account();
			account.setName("Test from Java");
			// Won't work.. this will throw 
			/*
			 * [UnexpectedErrorFault 
			 * [ApiFault  exceptionCode='UNKNOWN_EXCEPTION'
 				exceptionMessage='Destination URL not reset. 
 				The URL returned from login must be set in 
 				the SforceService'
			   ]
			 */
			conn.create(new SObject[]{ account });

			conn.logout();
		}
	}
}
But this did not work. Searching for this issue gave solutions that were not applicable when using the Force.com Web Services Connector. I talked to a colleague who had used .NET to communicate with the force.com APIs and he showed me code that required him to override a URL property, which did not exist in Java.

After some time experimenting, I discovered a solution which required the creation of another EnterpriseConnection but instead of using the user name and password, to use the session ID and server URL that is found from the results of the previous login. The following code demonstrates a successful test:

public class WorkingDemo 
{
	public static void main(String[] args) 
		throws ConnectionException 
	{
		System.out.println("Starting Working Demo");
		ConnectorConfig config = new ConnectorConfig();
		config.setManualLogin(true);	
		EnterpriseConnection conn = 
			Connector.newConnection(config);
		LoginResult loginResult = 
			conn.login("username", "pwd+token");
		if (!loginResult.getPasswordExpired())
		{
			System.out.println("Logged in");
			
			// once you log in, you need to create a new 
			// config and get the session and server 
			// details from the login results and 
			// create a new connection with this info
			ConnectorConfig newConfig = new ConnectorConfig();
			newConfig.setSessionId(
					loginResult.getSessionId());
			newConfig.setServiceEndpoint(
					loginResult.getServerUrl());
			conn = Connector.newConnection(newConfig);
	        
			Account account = new Account();
			account.setName("Test from Java");

			conn.create(new SObject[]{ account });
			
			System.out.println("The account has been created!");
			
			conn.logout();
		}
	}
}
I hope that this will save someone a few minutes or hours trying to figure out how to solve this exception when using the Enterprise WSDL. Please let me know if you know of any other solutions that will work.
Posted in Java, PaaS, Salesforce.com, Software Development, Tips & Tricks, Web Services | 3 Comments