1
失败我用下面的代码SOAP请求从Windows服务
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();
从编译的Windows应用程序运行时,该工作正常创建SOAP请求,但是从Windows服务调用时失败。从异常中捕获'500内部服务器错误'。
是否有任何理由为什么通过Windows服务运行可能导致这种情况?
在此先感谢您的帮助/咨询