Zach Skinner
Zach Skinner

Reputation: 159

error calling ReportingService2005.FindItems(); specifically concerning the BooleanOperatorEnum parameter

Having issues calling the ReportingService2005.FindItems() method from within powershell v2.

$rs = New-WebServiceProxy -Uri $ReportServerUri -Namespace SSRS.ReportingService2005 -UseDefaultCredential;

$searchCondition = New-Object SSRS.ReportingService2005.SearchCondition
$searchCondition.ConditionSpecified  = $true
$searchCondition.Name = "Name";
$searchCondition.Value = "Sales";
[SSRS.ReportingService2005.SearchCondition[]] $searchConditions = @($searchCondition)

$boolOp = [SSRS.ReportingService2005.BooleanOperatorEnum]::And

#Also tried bellow initialization of enum.
#[SSRS.ReportingService2005.BooleanOperatorEnum] $boolOp = 0

$rs.FindItems("/", $boolOp ,$searchConditions)

Executing the above gives the following error:

Cannot convert argument "1", with value: "And", for "FindItems" to type "SSRS.ReportingService2005.BooleanOperatorEnum": "Cannot convert value "And" to type "SSRS.ReportingService2005.BooleanOperatorEnum". Error: "Invalid cast from 'SSRS.ReportingService2005.BooleanOperatorEnum' to 'SSRS.ReportingService2005.BooleanOperatorEnum'.""

Any help would be greatly appreciated, Zach

Upvotes: 1

Views: 861

Answers (1)

Zach Skinner
Zach Skinner

Reputation: 159

Determined error to be related to the namespace paramater used in my webproxy. As it turns out, my script as posted runs successfully the first time it is excecuted in a session; it fails on successive executions in the same powershell session.

Found this article which explains the situation fairly well: http://www.vistax64.com/powershell/273120-bug-when-using-namespace-parameter-new-webserviceproxy.html

$rs = New-WebServiceProxy -Uri $ReportServerUri -UseDefaultCredential; 

$searchCondition = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1er_ReportService2005_asmx_WSDL.SearchCondition;
$boolop = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1er_ReportService2005_asmx_WSDL.BooleanOperatorEnum;

Upvotes: 2

Related Questions