WCF如何在post方法中返回字节数组并读取字节内容以打开为pdf

时间:2012-08-01 09:07:33

标签: c# wcf

WCF服务:

public byte[] GetEsignContent(string LoanID)
    {

        string strConnection;
        strConnection = ConfigurationManager.AppSettings["SqlConn"];
        WMSQLCon.DBSettings.ConnectionString = strConnection;

        byte[] bDocContent;
        IAppUsers.GetDocContent(Convert.ToInt32(LoanID), out bDocContent);
        return bDocContent;

    }

客户端APplication(aspx)

 int LoanID = Convert.ToInt32(Request.QueryString["LoanID"]);
            string URL = "http://PS30/IAPPService/IApp.svc/IApp/GetEsignDocument/" + LoanID.ToString(); ;
            HttpWebRequest hwrProg = (HttpWebRequest)WebRequest.Create(URL);
            HttpWebResponse hwrpProg = (HttpWebResponse)hwrProg.GetResponse();
            StreamReader sr = new StreamReader(hwrpProg.GetResponseStream(), Encoding.ASCII);
           // string str = sr.ReadToEnd();
           // byte[] bcontent = Convert.FromBase64String(sr.ReadToEnd());
           //byte[] bcontent = Encoding.ASCII.GetBytes(sr.ReadToEnd());  
            Response.ContentType = "Application/pdf";
            Page.Response.AddHeader("Content-Disposition", "inline;filename=xxx.pdf");
            Response.AddHeader("content-length", bcontent.Length.ToString());
            Response.BinaryWrite(bcontent);
            Response.Flush();
            Response.Close();
            sr.Close();

我无法获得在客户端应用程序的bcontent中使用的确切二进制文件。请帮助我......

0 个答案:

没有答案