2012-05-19 58 views
0

我想通過網絡服務來返回圖像返回大尺寸的字符串,所以我試圖將圖像轉換數據庫,然後到字節從字節爲base64字符串,並將其恢復到web服務,我對成功的一半但是由於字符串大小的限制或其他原因,我無法返回整個字符串希望?錯誤與IIS同時通過web服務

<%@ WebService Language="C#" Class="Service" %> 


using System; 

using System.Web; 
using System.Web.Services; 
using System.Web.Services.Protocols; 

using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Data.SqlClient; 

using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.IO; 

[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService] 
public class Service : System.Web.Services.WebService 
{ 
    public Service() { 

     //Uncomment the following line if using designed components 
     //InitializeComponent(); 
    } 

    [WebMethod] 
    public string IMAGE(string ID) 
    { 


     SqlConnection conn = new SqlConnection("Data Source=NEWCRISP19;Initial Catalog=masselango;Persist Security Info=True;User"); 
     conn.Open(); 
     SqlDataAdapter sdImageSource = new SqlDataAdapter(); 
     sdImageSource.SelectCommand = new SqlCommand("select ImageData from ImagesStore where ImageId=('" + ID + "')", conn); 
     DataSet dsImage = new DataSet(); 
     sdImageSource.Fill(dsImage); 

     byte[] blob = (byte[])dsImage.Tables[0].Rows[0][0]; 
     String c = Convert.ToBase64String(blob); 
     //c = c.Replace(" ", ""); 
     return c; 


    } 

} 

web.config未修改。

幫我retrieveing整個的base64字符串。

+1

你不能將它回爲一個字節數組? – freefaller

+0

雖然我需要通過爲base64字符串我的申請過程中,我用transfering正因爲如此,雖然它返回字符的一些極限傳遞,它一點兒也不通過整個數據 – user1389233

+0

我不知道一個限制上的長度通過web服務(但很高興被告知除此之外),但如果你看到一個問題,然後我不知道什麼是阻止你傳遞字節數組,然後轉換爲客戶端應用程序中的base64 sting * – freefaller

回答

0

我明白是你必須存儲的圖像數據庫二進制和您現在要找回它。

如果這是你想要的,那麼請檢查該鏈接Insertion and Retrieval of image in binary

+0

OP在詢問關於webservices的問題,看起來好像他們對事物的數據庫端進行了排序 – freefaller