欢迎您来到 数字平台。 您尚未登录。[登录] [注册新用户]
当前位置: 论坛首页 / 栏目 产品与服务 / 文章 393

点击:14770

[顶层访客留言] [回复顶层(需要先登录)] [表状] [详细]
[回复留言] [回复(需要先登录)] [引用(需要先登录)]普通文章第 1 楼
文章id: 393
求助:在WEB页下载挂接资源的程序问题

作者: liujp


编一简单页面,基于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();
    }
}


 



发表时间: 2009-01-14 10:59:11



  • 普通文章 求助:在WEB页下载挂接资源的程序问题 liujp 2009-01-14 10:59:11[点击:14770]
  • 普通文章 回复:求助:在WEB页下载挂接资源的程序问题 xietao 2009-01-14 22:47:15 (ID:394) [点击:1178]
  •  

    在线用户
    访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客   访客访客
    当前栏目在线用户数 71, 总在线用户数 73