As a particular example of a function satisfying Arturo Magidin's conditions,
$$f(x) = \begin{cases}
1/\sqrt x & \text{if }0 < x \le 1 \\
1/x^2 & \text{if }1 < x
\end{cases}$$
ought to work. In particular, $\displaystyle \int_0^\infty f(x)\;dx = 3$ and $f(f(x)) = x$.
Addendum: If you don't want a piecewise defined function, you could write $f$ above as $f(x) = \exp\;g(\log x)$, where
$$g(u) = -\frac34 |u| - \frac54 u.$$
Of course, this is just a notational trick; $f$ still has a "kink" at $x=1$ due to the non-differentiability of $|u| = |\log x|$ there. However, it's a trick that points in a useful direction: if you also want the function to be everywhere differentiable, you can replace $|u| = \sqrt{u^2}$ in the definition of $g$ above with the hyperbola $\sqrt{1+u^2}$ to get
$$\tilde g(u) = -\frac 34 \sqrt{1 + u^2} - \frac 54 u,$$
and thus
$$\tilde f(x) = \exp \left( -\frac 34 \sqrt{1 + (\log x)^2} - \frac 54 \log x \right).$$
This function $\tilde f$ still satisfies $\tilde f(\tilde f(x)) = x$, and since $\tilde f(x) < f(x)$ for all $x$, we know that its integral from 0 to infinity must be less than 3. (Actually, it is about 2.19574343.)