I'm creating SOAP Request using the following code
public static string SubmitSoapRequest(string url,
string ns,
string operation,
string requestXml,
bool responseNodeOnly)
{
// make sure the namespace has a trailing slash
ns = ns.TrimEnd('/') + '/';
// format soap request
string soap = string.Format(SOAP_REQUEST_XML, ns, operation, requestXml);
// format soap action
string soapAction = string.Format(@"{0}{1}", ns, operation);
// initialize web request
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
// add header and other soap params
req.Headers.Add("SOAPAction", soapAction);
req.ContentType = @"text/xml;charset=""utf-8""";
req.Accept = "text/xml";
req.Method = "POST";
// make soap request
using (Stream s = req.GetRequestStream())
using (StreamWriter sw = new StreamWriter(s))
sw.Write(soap);
// get response from remote web-service
WebResponse response = req.GetResponse();
this works fine when running from a compiled windows app, but fails when calling from a Windows Service. A '500 Internal Server Error' is caught from the exception.
is there any reason why running via a windows service could be causing this?
thanks in advance for any help / advice