编一简单页面,基于web调用libraryws.asmx来实现数据库的查询和挂接资源的下载.程序在2008.08.01以前的版本查询和下载均正确,2008.11.20又升级了libraryws.asmx后,对挂接资源下载是报错
实例验证错误:“OtherError”不是 ErrorCode 的有效值。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: 实例验证错误:“OtherError”不是 ErrorCode 的有效值。
源错误:
行 3444: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://dp2003.com/dp2libraryws/library.asmx/GetRes", RequestNamespace="http://dp2003.com/dp2libraryws/library.asmx", ResponseNamespace="http://dp2003.com/dp2libraryws/library.asmx", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
行 3445: public Result GetRes(string strResPath, int nStart, int nLength, string strStyle, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] out byte[] baContent, out string strMetadata, out string strOutputResPath, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] out byte[] baOutputTimestamp) {
行 3446: object[] results = this.Invoke("GetRes", new object[] {
行 3447: strResPath,
行 3448: nStart,
|
在vs2005中调试代码在执行到最后一次读二进制时报错,在以文代码中标记:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using DigitalPlatform;
using DigitalPlatform.CirculationClient;
using DigitalPlatform.Xml;
using DigitalPlatform.LibraryServer;
using System.Xml;
public partial class down : System.Web.UI.Page
{
CookieContainer Cookies = new System.Net.CookieContainer();
wsLibrary.Library lib = new wsLibrary.Library();
wsLibrary.Result result = new wsLibrary.Result();
protected void Page_Load(object sender, EventArgs e)
{
//eg.:郭沫若研究/8/object/0
string strResPath = Request.QueryString["path"];
//init lib\
//eg. http://210.41.165.4/dp2libraryws/library.asmx
lib.Url = (string)Session["SERVERURL"];
lib.CookieContainer = (CookieContainer)Session["LOGIN"];
string strError = "";
int nStart = 0;
int nLength = 10000000;
string strStyle = "content,data,metadata,timestamp,outputpath";// data/metadata/timestamp/outputpath之一
byte[] baContent;
string strMetaData;
string strOutputResPath;
byte[] baOutputTimestamp;
XmlDocument doc = new XmlDocument();
result = lib.GetRes(strResPath,
nStart,
nLength,
strStyle,
out baContent,
out strMetaData,
out strOutputResPath,
out baOutputTimestamp);
if (result.Value < 0)
{
strError = result.ErrorInfo;
return;
}
doc.LoadXml(strMetaData);
string strLocalPath = doc.FirstChild.Attributes["localpath"].Value;
string strHeader = "attachment;filename=" + Server.UrlEncode(System.IO.Path.GetFileName(strLocalPath));
Response.Clear();
Response.ClearContent();
Response.ContentType = doc.FirstChild.Attributes["mimetype"].Value;
Response.AppendHeader("Content-Disposition", strHeader);
while (nStart <= result.Value)
{
Response.BinaryWrite(baContent);
nStart += baContent.Length;
// 代码在此运行到最后异常
result = lib.GetRes(strResPath,
nStart,
nLength,
strStyle,
out baContent,
out strMetaData,
out strOutputResPath,
out baOutputTimestamp);
}
Response.Flush();
Response.Close();
//Response.End();
}
}