我試圖從一個PowerShell腳本調用了SharePoint的Copy.asmx WebService的:out參數沒有填寫
$copyWS = .\Connect-WebService.ps1 $copyWsdlUrl -requiresAuthentication
$copyWS.UseDefaultCredentials = $true
[FieldInformation[]]$fieldInfos = $null
[System.Byte[]]$data = $null
$copyWS.GetItem($fileUrl, [ref]$fieldInfos, [ref]$data)
結果:返回的GetItem 0成功,但$ fieldInfos和$ data是$ null。如果我從C#控制檯應用程序執行相同的操作,它會正常工作,data.Length等於我的文件長度。
Copy copyWS = new Copy();
copyWS.UseDefaultCredentials = true;
FieldInformation[] fieldInfos = null;
byte[] data = null;
uint result = copyWS.GetItem(fileUrl, out fieldInfos, out data);
Console.WriteLine(result);
Console.WriteLine(data.Length);
我的錯誤在哪裏,或者這是一個PowerShell錯誤?
繼beefarino的意見,我叫$ copyWS.GetItem並獲得:
System.UInt32 GetItem(string Url,
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3http___moss__vti_bin_Copy_asmx.FieldInformation[]&, jfww_71i, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null Fields,
System.Byte[]&, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Stream)
所以我看參數吧,我甚至改變了$ fieldInfos的類型,以顯示全名Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3http___moss__vti_bin_Copy_asmx.FieldInformation[]
但無濟於事。
好一點,爲$ copyWS.GetItem我得到:System.UInt32的GetItem (string Url,Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3http ___ moss__vti_bin_Copy_asmx.FieldInformation []&,jfww_71i,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = null Fields,System.Byte []&,mscorlib,Version = 2.0 .0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089 Stream) – Hinek 2011-01-26 14:43:50