I am having similar problem, as I need to output a document/literal wrapped response. I have very little experience here and it is making my head hurt. I have setup web service based on MoodleDoc: Development:Creating a web service and a web service function. Looking at files webservice/lib.php and webservice/soap/locallib.php you will have to hack those files or write your own class and from there pass in the location of wsdl file. Unsure how entirely works but a virtual class is created and methods that you created in your externallib.php are used in that virtual class. I will keep investigating...