Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Writing the bean class

...

We now have to excerptINLINE

write the bean class

...

Creating the bean class

Preparing an Eclipse project

In order to ease the development we will now make use of Mavens ability to create Eclipse projects. From the http-handler-su main folder run the following comand:

...

...

This will cleanup any existing Eclipse config (eclipse:clean) and create a new eclipse project (eclipse:eclipse).
When done it should post something like:

...

...

Importing the project into Eclipse

Now it's time to start up Eclipse workbench. Choose File > Import > Existing Projects into Workspace.
Then select the projects root directory and press OK. A project named http-handler-su should now be visible inside the Import window's projects list. Make sure it's checkbox is selected and press finish.
The project should now appear in your Package Explorer view.

Be sure you have specified the M2_REPO classpath variable to point on your local Maven repository which is located in your home folder.
For example: /home/lhe/.m2/repository
If you don't know how to specify this variable refer to the Eclipse documentation or Google it.

Create the bean class file

Next thing to do is creation the bean class. For this select the src/main/java folder in your project. Now delete everything inside this folder.

Now select File > New > Class. In the dialog enter the following:

*

...

*

Then hit Finish to create the class. Eclipse will also implements implement the interface's only method for you:

...

*

...

*
This method is responsible for handling incoming messages.

Handling incoming messages

We assume (and do not further check) that each incoming message exchange is of type InOut MEP. Feel free to improve this and check for the correct Message Exchange Pattern.

We extract the first attachment of the message by name. The name is equal to the filename. After this we have the original filename in the
fileName variable and the file content in the content variable (as DataHandler object).
For the sake of simplicity we just write the contents into a temporary file and use this file for sending it back to the http-consumer-su.

...

This is of course a stupid example, so just imagine you now convert this file into another format and send the result back.
You can do such a logic if you want. For this you can refer for example to OpenOffice running in headless mode in combination with the JODConverter of "Arts of Solving". This will enable you to convert for example a .odt document into a .pdf document. But this is really out of scope now.

The finished class

...

...

Feel free to play around with this class after you ran it once sucessfully. There is enough room for improvements.

Now the handler SU is ready for work. Let's move on to creating the service assembly.

...

Proceed to the next step



...