Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!

Ryan Heaton is an engineer, architect, and consultant specializing the Web service design and development. Ryan has architected a wide variety of successful Web service applications and frameworks. One of his projects, Enunciate, has been released as a popular open-source Web service development framework. He has performed technical interviews for scores of candidates probing all aspects of Web service design and implementation. Ryan is a DZone MVB and is not an employee of DZone and has posted 9 posts at DZone. View Full User Profile

OFX4J: Java Web Service APIs for Interfacing with Financial Institutions

July 22, 2008 AT 10:56 AM
  • submit to reddit

OFX4J has been released!

OFX4J is a Java implementation of Open Financial Exchange, which defines web service APIs for interfacing with financial institutions. The OFX4J library includes support for both client-side and server-side implementations of both version 1 and version 2 of the OFX specification.

As an example, let's consider the OFX4J client-side interface, which can be used, for example, to download your financial transactions from your bank or credit card institution. OFX4J comes with an initial set of financial institution data, but you can load your own if your financial institution isn't included.

Consider the following code for downloading your bank statement:

//the financial institution data is loaded or created
//the FinancialInstitutionData interface defines
//what is required to interface with a financial institution.
FinancialInstitutionData data = ...;
FinancialInstitutionService service
= new FinancialInstitutionServiceImpl();
FinancialInstitution fi = service.getFinancialInstitution(data);

//get a reference to a specific bank account at the FI
BankAccountDetails bankAccountDetails
= new BankAccountDetails();

//routing number to the bank.
bankAccountDetails.setRoutingNumber("11111111");
//bank account number.
bankAccountDetails.setAccountNumber("1234-5678");
//it's a checking account
bankAccountDetails.setAccountType(AccountType.CHECKING);

BankAccount bankAccount
= fi.loadBankAccount(bankAccountDetails, "username", "password");

//read the statement (transaction details, etc.)
// for a given time period.
Date startDate = ...;
Date endDate = ...;
AccountStatement statement
= bankAccount.readStatement(startDate, endDate);

// get a reference to a specific credit card
// account at your FI
CreditCardAccountDetails ccDetails
= new CreditCardAccountDetails();
ccDetails.setAccountNumber("1234-567890-1111");
CreditCardAccount ccAccount
= fi.loadCreditCardAccount(ccDetails, "username", "password");

// read the statement (transaction details, etc.)
// for a given time period.
Date startDate = ...;
Date endDate = ...;
AccountStatement statement
= ccAccount.readStatement(startDate, endDate);

Server-side development is just straightforward, consisting of implementing a simple interface and publishing it with a simple Servlet implementation:

/**
* Basic interface for an OFX server.
*
* @author Ryan Heaton
*/
public interface OFXServer {

/**
* Get a response for the given request.
*
* @param request The request.
* @return The response.
*/
ResponseEnvelope getResponse(RequestEnvelope request);
}

 

 

Location: 
http://ofx4j.sourceforge.net/
0
Average: 1 (1 vote)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Karthik Narayanan replied on Mon, 2009/11/09 - 1:23am

your code is very clear and descriptive about getting data from a financial institution, but it is not very clear about other stuff such as how can i get the ccnums from the users username and password. is this possible????

 

 

 

Legin Antony replied on Fri, 2010/10/22 - 1:05am

I am new to the OFX1 (Sgml) section, but the ofx4j API looks "Awsome" yaar...!!

Hope it will help us for the OFX conversions. But can you please share the some example for basic OFX conversion?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.