There are various research papers related to this topic and many methods have been tried.
Assuming you cannot use 35 cameras as mentioned above or a Hawk-eye camera based system, you may want to consider a radio transmitter placed inside the ball. This generates a signal that is in turn is picked up by antenna attached to the goalposts (see this patent document for more details).
There are some distinct advantages to this technology, the signal
transmitted by the ball shouldn’t be significantly affected by
weather, lighting or the presence of players. As long as the antenna
receive the radio waves, a computer system can theoretically calculate
the ball’s position. A disadvantage, is the necessity of placing a
radio transmitter within the football. Firstly, the exact point from
which the signal is transmitted will determine the position of the
ball. This seems obvious, but if the transmitter moves within the
ball, the system will deem the ball to be moving, even if it isn’t.
This has significant implications when millimetre accuracy is demanded
and the ball deforms significantly when struck.
Source: Here
Something similar is implemented in the iBall recently approved by FIFA. Inside the soccer ball are sensors that wrap around the ball in both directions.
The sensors inside the ball consist of a web of copper wire that uses induction, allowing communication with an antenna array that is mounted to the goal frame. The second that the entire ball has passed the goal line, the system sends a signal to a watch that the referee wears allowing the referee to know the goal was made.
Adidas are also developing Smart Ball technology. The ball has a computer chip inside that will relay information to the referee. This also makes use of cameras however. Cameras are placed at a certain angle so that it is clear when the ball crosses the goal line.