Welcome to the Wefugees Community and thank you for reaching out to us.
Unfortunately, asylum and humanitarian protection can only be given when people are on Germany territory. It is not possible to apply for a humanitarian visa at the German embassy, for instance.
Once you are in Germany, you can apply for asylum and your application will be assessed individually by the German authories (by the so-called BAMF). For people from Somalia, there is a quite good chance that they are recognised as refugees by the German authorities and subsequently will be issued residence permits. However, as I mentioned before, every case is checked individually and it highly depends on your personal circumstances, the statements you make at the so-called interview ("Anhörung") and your reasons for fleeing Somalia.
I hope these information are useful for you and please don't hesitate to get back to us with any further questions.
All the best,