Putting the code in a separate file is best practice but you could also split the declaration up:
Code:
var soapRequest = '<' + '?' + 'xmlversion="1.0"encoding="utf-8"?>' +
As to your subsequent problem that's a different one altogether. You'll need to start a new thread, possibly in the SharePoint forum, and give details of what you're attempting and what's happening.