Asp.net 检索word文档时出现Web服务错误
尝试通过webservice检索word文档时出错Asp.net 检索word文档时出现Web服务错误,asp.net,httpwebresponse,Asp.net,Httpwebresponse,尝试通过webservice检索word文档时出错 HttpWebRequest request; Uri uri = new Uri(serverUrl + "/bare.aspx/" + Request.PathInfo); request = (HttpWebRequest)WebRequest.CreateDefault(uri); request.Ke
HttpWebRequest request;
Uri uri = new Uri(serverUrl +
"/bare.aspx/" + Request.PathInfo);
request = (HttpWebRequest)WebRequest.CreateDefault(uri);
request.KeepAlive = false;
request.AllowAutoRedirect = false;
request.ReadWriteTimeout = -1;
request.Timeout = -1;
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Method = "POST";
request.ContentType = "application/octet-stream";
// Serialize argument into request stream
Hashtable arguments = new Hashtable();
arguments["templateFile"] = templateFile;
arguments["hSetDataSource"] = hSetDataSource;
arguments["hSetRepeatBlock"] = hSetRepeatBlock;
arguments["messageForEmptyWord"] = messageForEmptyWord;
arguments["hImageBefore"] = hImageBefore;
arguments["hImageAfter"] = hImageAfter;
arguments["hImageInsideRepeater"] = hImageInsideRepeater;
MemoryStream buf = new MemoryStream();
BinaryFormatter fmt = new BinaryFormatter();
fmt.Serialize(buf, arguments);
request.ContentLength = buf.Length;
Stream reqStream = request.GetRequestStream();
buf.WriteTo(reqStream);
reqStream.Close();
buf.Close();
// Retreive word document from response and return it
// TODO: refactor this to stream directly into the response
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
当我检查webservice响应(HttpWebResponse resp)时,我得到以下错误:
System.Net.WebException:远程服务器返回错误:(404)未找到。
我不明白问题出在哪里,提前感谢您的帮助。您没有到达终点。
404
表示服务器找不到您请求的URL
。将.asmx
URL放入web浏览器,验证其正确性。如果这样做有效,那么请确保您的代码使用的是相同的URL。如果您试图访问Web服务,您的URL应该是bare.asmx而不是bare.aspx吗?我尝试了“asmx”,但我得到了相同的错误。我发现了这个错误,但这对我的情况没有帮助:但是这个脚本应该创建一个临时文档吗?为什么他找不到?