Post by tjtvs on Jun 1, 2011 2:18:39 GMT -6
Hi,
I added http://remotesite/_vti_bin/copy.asmx as the webreference to my windows application and gave the name WSCopy
SPSecurity.RunWithElevatedPrivileges(delegate()
{
string webUrl = "http://remotesite";
WSCopy.Copy copyService = new WSCopy.Copy();
copyService.Url = webUrl +"/_vti_bin/copy.asmx";
copyService.PreAuthenticate = true;
copyService.Credentials = new NetworkCredential("username", "password", "domain");
string sourceUrl = @"D:\server\RocketLife\ 2011\April 28\test.ex";
string[] destinationUrl = { http://remotesite/external/Beta%20Builds/2011-0-02.1.1ATest/test.ex };
WSCopy.CopyResult cResult1 = new WSCopy.CopyResult();
WSCopy.CopyResult cResult2 = new WSCopy.CopyResult();
WSCopy.CopyResult[] cResultArray = { cResult1, cResult2 };
WSCopy.FieldInformation fFiledInfo = new WSCopy.FieldInformation();
fFiledInfo.DisplayName = "Description";
fFiledInfo.Type = WSCopy.FieldType.Text;
fFiledInfo.Value = "Sample Description";
WSCopy.FieldInformation[] fFiledInfoArray = { fFiledInfo };
FileStream strm = new FileStream(sourceUrl, FileMode.Open, FileAccess.Read);
byte[] fileContents = new Byte[strm.Length];
byte[] r = new Byte[strm.Length];
int ia = strm.Read(fileContents, 0, Convert.ToInt32(strm.Length));
strm.Close();
uint copyresult = copyService.CopyIntoItems(sourceUrl, destinationUrl, fFiledInfoArray, fileContents, out cResultArray);
});
copyService.CopyIntoItems is returning Zero,but the file is not showing uploaded.The same code works fine when i upload the file to local sharepoint site using the local Copy.asmx webservice.
iam giving the values of ErrorCode and ErrorMessage in the
output parameter WSCopy.CopyResult[] cResultArray for reference
ErrorCode=UnKnown
ErrorMessage=Object reference not set to an instance of an object
Thank you
I added http://remotesite/_vti_bin/copy.asmx as the webreference to my windows application and gave the name WSCopy
SPSecurity.RunWithElevatedPrivileges(delegate()
{
string webUrl = "http://remotesite";
WSCopy.Copy copyService = new WSCopy.Copy();
copyService.Url = webUrl +"/_vti_bin/copy.asmx";
copyService.PreAuthenticate = true;
copyService.Credentials = new NetworkCredential("username", "password", "domain");
string sourceUrl = @"D:\server\RocketLife\ 2011\April 28\test.ex";
string[] destinationUrl = { http://remotesite/external/Beta%20Builds/2011-0-02.1.1ATest/test.ex };
WSCopy.CopyResult cResult1 = new WSCopy.CopyResult();
WSCopy.CopyResult cResult2 = new WSCopy.CopyResult();
WSCopy.CopyResult[] cResultArray = { cResult1, cResult2 };
WSCopy.FieldInformation fFiledInfo = new WSCopy.FieldInformation();
fFiledInfo.DisplayName = "Description";
fFiledInfo.Type = WSCopy.FieldType.Text;
fFiledInfo.Value = "Sample Description";
WSCopy.FieldInformation[] fFiledInfoArray = { fFiledInfo };
FileStream strm = new FileStream(sourceUrl, FileMode.Open, FileAccess.Read);
byte[] fileContents = new Byte[strm.Length];
byte[] r = new Byte[strm.Length];
int ia = strm.Read(fileContents, 0, Convert.ToInt32(strm.Length));
strm.Close();
uint copyresult = copyService.CopyIntoItems(sourceUrl, destinationUrl, fFiledInfoArray, fileContents, out cResultArray);
});
copyService.CopyIntoItems is returning Zero,but the file is not showing uploaded.The same code works fine when i upload the file to local sharepoint site using the local Copy.asmx webservice.
iam giving the values of ErrorCode and ErrorMessage in the
output parameter WSCopy.CopyResult[] cResultArray for reference
ErrorCode=UnKnown
ErrorMessage=Object reference not set to an instance of an object
Thank you