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服務運行可能導致這種情況?
在此先感謝您的幫助/諮詢