2011-03-02 56 views
0

我正在嘗試使用名爲copy.asmx的sharepoint webservices從文檔下載文件。它的文件大小爲100 KB。使用sharepoint copy.asmx下載文件時出現問題

但它沒有下載文件。

Web服務iteself在Web服務響應中返回空流(out byte [] Stream)。是任何內存問題。

而且它返回像「download_document()內存不足」

注:我使用的MFP打印機,查看該應用程序。

回答

0

請嘗試以下功能。你需要通過FileURL(文件的完整網址),標題(你想給下載文件的通過名稱)。

public string DownLoadfiletolocal(string FileURL, string Title) 
{ 

//Copy.Copy is a webservice object that I consumed. 

Copy.Copy CopyObj = new Copy.Copy(); 
CopyObj.Url = SiteURL + "/_vti_bin/copy.asmx"; // Dynamically passing SiteURL 
NetworkCredential nc2 = new NetworkCredential(); 
nc2.Domain = string.Empty; 
nc2.UserName = _UserName; 
nc2.Password = _Password; 


string copySource = FileURL; //Pass full url for document. 

Copy.FieldInformation myFieldInfo = new Copy.FieldInformation(); 
Copy.FieldInformation[] myFieldInfoArray = { myFieldInfo }; 
byte[] myByteArray; 

// Call the web service 
uint myGetUint = CopyObj.GetItem(copySource, out myFieldInfoArray, out myByteArray); 

// Convert into Base64 String 
string base64String; 
base64String = Convert.ToBase64String(myByteArray, 0, myByteArray.Length); 

// Convert to binary array 
byte[] binaryData = Convert.FromBase64String(base64String); 

// Create a temporary file to write the text of the form to 
string tempFileName = Path.GetTempPath() + "\\" + Title; 

// Write the file to temp folder 
FileStream fs = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite); 
fs.Write(binaryData, 0, binaryData.Length); 
fs.Close(); 

return tempFileName; 

} 
+0

我正在使用python應用程序來使用web服務。 – TinTin 2011-03-02 12:26:45

+0

此功能需要傳遞證書以及您要下載的文檔的完整URL。我認爲這對你來說已經足夠了 – 2011-03-02 12:29:41

相關問題