How do you integrate with Java – when you’re hitting the SOAP WSDL endpoints?  I use WSC.  Before that, I used to use Apache’s WSDL2Java.

WSC is pretty cool – run it against your enterprise WSDL (say – it works with partner / metadata too), and you get a little JAR that you can include, which lets you write really simple, straightforward code.  Like this:

ConnectorConfig config = new ConnectorConfig();
connection = Connector.newConnection(config);
QueryResult queryResults = connection.query("SELECT Id, FirstName, LastName, Account.Name " +
"FROM Contact WHERE AccountId != NULL ORDER BY CreatedDate DESC LIMIT 5");
if (queryResults.getSize() > 0) {
for (int i=0;i < queryResults.getRecords().length;i++) {
// cast the SObject to a strongly typed Contact
Contact c = (Contact)queryResults.getRecords()[i];
System.out.println("Id: " + c.getId() + " - Name: "+c.getFirstName()+" "+
c.getLastName()+" - Account: "+c.getAccount().getName());

Tell me that’s not pretty!  No pain, plenty of gain.

To learn more, check out the article we’ve just published: Introduction to the Web Services Connector

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS