尝试通过webservice
检索word文档时出错 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)Not Found。
我不明白问题出在哪里,请事先感谢你的帮助。
答案 0 :(得分:0)
您没有点击端点。 404
表示服务器找不到您要求的URL
。将您的.asmx
网址放入网络浏览器即可验证。如果可行,请确保您的代码使用相同的URL。