What is necessary to exchange messages between aliens? Lets assume that two extreme intelligent species in the universe can exchange morse code messages for the first time. A can send messages to B and B to A, both have unlimited time, but they can not meet.
Is it possible to transfer information between both species? What would be the mathematical precondition for information exchange?
If A sends "Hello friend" to B, he might not understand this message, but could A train B to understand the code of A?
For example A could expect, that B will know logic and first send some definitions like the generation of natural numbers and primitive logic or calculations.
Has there been a publication in a journal on this topic?
 A: There is a lot of discussion on this kind of stuff in the philosophical literature as well (under the title "radical interpretation"). In the second chapter of Quine's Word and Object, Quine presents a thought experiment where a linguist goes to study a tribe whose language is completely foreign to the rest of the world. The linguist somehow manages to figure out what the native uses to assent/dissent to questions, and begins pointing to, say, a rabbit and asking "Gavagai?" The native then assents or dissents according to whether or not the term 'gavagai' denotes the object pointed to. The problem is similar to the one you raised, for even though we have access to what counts as assenting/dissenting in the native language, Quine argues we still cannot uniquely fix the meaning/interpretation of the terms in the native language, because there are a large number of radically different interpretations which are consistent with every such use of 'gavagai'.
If you want to read about this in the philosophical literature, Quine's Word and Object is a good place to start (I'd only read the first couple of chapters though). Also, Donald Davidson's "The Inscrutability of Reference" is a good article, as well as David Lewis's "Radical Interpretation." You can probably find more resources from there. This also links up to a lot of rule-following problems in the philosophy of language (see Kripke's classic Wittgenstein on Rules and Private Language, Chps. 1-2).
A: there is also a biological/anthropological answer. You didn't mention that the aliens were an advanced civilization, but only that they had enough technology to communicate with us.
The, there is this tribe in the Amazonia (in Brazil), called the piraja. they do not understand numbers larger than 4 or 5. the rest means "many". I suspect this is not cultural, but some kind of inbreed mutations that results in acalculia. Many people on our society suffer from acalculia, which involves average or even above average intelligence but total incapacity to grasp the meanaing of the natural numbers. Thus, if the aliens were acalculic but otherwise intelligent, they would find it difficult to decipher a code based on math! just my two cents on a fringe issue that could bear some weight in the answer
A: Communication with extraterrestrial intelligence has actually received a fair amount of (theoretical) attention. 
If you have seen the film Contact or read the book (by Carl Sagan), you have seen a brief description of what seems to be the best current protocol. The message Sagan describes in the novel seems to follow the pattern of Lincos, a language developed by mathematician Hans Freudenthal. The idea, as you suggest, is to use mathematical language. The Wikipedia entry does a decent job of explaining how the messages would proceed. You may enjoy to know that messages coded in Lincos have actually been sent to space, in 1999 and 2003. Lincos itself was detailed in the book Lincos: Design of a Language for Cosmic Intercourse, Part 1. (Part 2 was never written.)
Let me quote from Wikipedia:

[Lincos] begins with a simple pattern of pulses intended to establish the terminology for natural numbers and basic arithmetic (addition, subtraction, multiplication and division) in base two. The concepts of equality, comparison, variables and constants are also illustrated by a series of examples, and then finally propositional logic, set theory and first-order logic. The next section of the Lincos dictionary establishes vocabulary for describing time, introducing means for measuring durations, referring to moments in time, and talking about past and future events. The third section is perhaps the most complex, and attempts to convey the concepts and language necessary to describe behavior and conversation between individuals. It uses examples to introduce actors speaking to each other, asking questions, disapproving, quoting other people, knowing and wanting things, promising, and playing. Finally, the fourth section describes the concepts and language relating to mass, space, and motion. This last section goes so far as to describe physical features of human beings and of the Solar system.

A few more details of the first two sections are presented in Contact. 
For more details of research in these area, see here. The main issue with Lincos is the underlying assumption that the language of mathematics is universal, which can be traced back to the question of whether mathematics is created or discovered. This universality, its "unavoidable character", is somewhat disputed (again, at least theoretically). See for example the book 

Conversations on mind, matter, and mathematics. Jean Pierre Changeux, and Alain Connes. Edited and translated by M. B. DeBevoise. Princeton University Press, 1995,

and for another view, the works of Mario Livio, in particular Is God a mathematician?
(Of course, your question is a bit harder, since it does not require than the originator of the message is human. But Lincos is still the most developed protocol and, at least, should give you an idea of the minimum mathematical assumptions that an exchange would require.)
