Enterprise Integration Zone is brought to you in partnership with:

Willie Wheeler is a Principal Applications Engineer with Expedia, working on continuous delivery, including build automation, test automation, configuration management and application performance management. He's also the lead author of the book Spring in Practice (Manning). Willie is a DZone MVB and is not an employee of DZone and has posted 23 posts at DZone. You can read more from them at their website. View Full User Profile

Spring Integration: A Hands-On Tutorial Part 2

  • submit to reddit

Integrating web-based RFI forms

[The code for this section is available here]

Request for information forms, or RFIs, are an important piece of the lead management domain. They allow prospective customers to find out more, and they result in a lead being created in the lead management system. Qualifying reps or else salespersons can then pull the lead out of the CRM and follow up, providing the requested information. In the context of our hypothetical online university, enrollment advisors might for example contact prospective students with information about academic programs, financial aid and so on.

Figure 2 shows how our web-based RFI fits into the overall scheme of things.

Figure 2: We're going to accept leads from web-based RFI forms.

Let's go through the various steps involved in adding the new web-based RFI to the overall integration.

Add the lead generation website

RFI forms live on customer-facing lead generation websites, so we're going to need a separate Maven module. See the code download for the leadgen module. Normally this would be an entire website that describes university events, academic programs, student and faculty profiles, accreditation information and that sort of thing. Here though we're interested in only the RFI form itself, so that's all our sample lead gen site has.

When the user submits the RFI, it goes to a web MVC controller (part of the lead gen site), which in turn passes it to a service bean (still part of the lead gen site). The service bean uses HttpClient to send an HTTP POST request through the firewall to the CRM, which would typically live on the internal network. So as this example shows, we can integrate systems in the DMZ with those on the internal network.

Once the HTTP request makes it onto the bus (and we'll show how that works shortly), we have to have a way to transform it into a Lead object that we can place on the newLeadChannel. The next section shows how to do that.

Transform the HTTP POST request parameters to a Lead

In the first tutorial we created a transformer bean to convert Leads into MailMessages so we could send prospective students a confirmation e-mail. Here we're going to create another transformer bean, this time to map the HTTP POST request to a Lead. Listing 4 shows how it's done.

We've already covered the mechanics of creating a transformer bean, so there's no need to repeat that. In this case, the HTTP channel adapter (we'll see it momentarily) creates a Message with a Map of HTTP parameters as its payload, so that's why our @Transformer method takes a Map as an input.

The last step is once again to configure the message bus.

Configure the message bus to add the new pipeline

There's not much of a change to applicationContext-integration.xml, so instead of showing the whole configuration, listing 5 concentrates on the parts that change.

Listing 5. Updates to /WEB-INF/applicationContext-integration.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"

... other namespace declarations ...


... other schema locations ...


class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />


<channel id="httpLeadChannel" />

<transformer input-channel="httpLeadChannel" output-channel="newLeadChannel">
<beans:bean class="crm.integration.transformers.HttpToLeadTransformer" />

... other message bus configuration ...


We've added the new http namespace and schema location, and we're using it to declare an inbound HTTP channel adapter that handles requests coming to the /leads path, thanks to the BeanNameUrlHandlerMapping. (See Spring Web MVC if you're unfamiliar with how that works.) The full URI is


and that's the destination URI for the HTTP POST requests that the lead gen website's HttpClient sends. The inbound channel adapter listens for HTTP POST requests mapping to that URI and then pushes a Message containing the parameter map onto the httpLeadChannel. The bus takes over from there.

We have a transformer definition, but we've already seen one of those so we won't cover it again.

To try it out, start up your CRM and lead gen site, and direct your browser to


The RFI form as it currently stands doesn't provide any way to specify the country, so the country will be null and RFI leads will all route through the domestic channel and end up in the local CRM. So you don't need to start up the external CRM.

One more before we call it a day: an e-mail based RFI.

spring-integration-demo-5.zip29.93 KB
spring-integration-demo-6.zip42.65 KB
spring-integration-demo-7.zip44.91 KB
Published at DZone with permission of Willie Wheeler, author and DZone MVB.

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



Morali Julien replied on Wed, 2010/02/24 - 12:52pm

Hi Willie,


Thx for this post, it was really helpfull to me.

Still, I have a problem configuring an IMAP access to a gmail account.

As GMail's usernames are "xxx@gmail.com", the store-uri parameter is incorrect because of the "@"which is considered as a separator...

 I read that you mentionned a gmail account for testing, so did you manage to solve this problem ???


Thx by advance for your help !


Comment viewing options

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