开发者

PowerShell - Exception New-WebServiceProxy SOAP

When I execute my code, the following exception was thrown (German):

Ausnahme beim Aufrufen von "GetListItems" mit 7 Argument(en): "Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."

Is it possible to get more details about the Soap Server Exception?

My code:

$url = "http://mysharepoint.de/websites/test/"
$docBib = "TestDocLib"

$sitesWS = New-WebServiceProxy ($url + "_vti_bin/Lists.asmx") -UseDefaultCredential
$sitesWS.Proxy = New-Object System.Net.WebProxy("")

$xmlDoc = New-Object System.Xml.XmlDocument
$xmlDoc.LoadXml("<Document><Query /><ViewFields /><QueryOptions /></Document>")
$queryNode = $xmlDoc.SelectSingleNode("//Query")
$viewFieldsNode = $xmlDoc.SelectSingleNode("//ViewFields")
$queryOptionsNode = $xmlDoc.SelectSingleNode("//QueryOptions")

$开发者_开发问答queryNode.InnerXml = "<Where></Where>"

$sitesWS.GetList("test")
$result = $sitesWS.GetListItems($docBib, $null, $queryNode, $viewFieldsNode, $null, $queryOptionsNode, $null)


I've struggled with managing Sharepoint via web services as well. So I can tell how picky these can be with their arguments. This is how I set the GetListItems call up - and got it working:

$xmlDoc = new-object System.Xml.XmlDocument
$viewFields = $xmlDoc.CreateElement("ViewFields")
$queryOptions = $xmlDoc.CreateElement("QueryOptions")
$queryOptionsString = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>TRUE</DateInUtc><ViewAttributes Scope='RecursiveAll' />"
$queryOptions.set_innerXML($queryOptionsString)
$query = $xmlDoc.CreateElement("Query")

$sitesWS = $service.GetListItems($docBib, "", $query, $viewFields, "", $queryOptions, "")

The trick, I think is that I create XML elements for each of $viewFields,$queryOptions and $query (but both viewFields and query can be empty except for their 'root' tags).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜