我试图从一个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