Dan Black
Dan Black

Reputation: 1217

Powershell Webservice Method definition changes

I am using powershell to deploy our SSRS reports, but have come across an issue when deploying multiple reports.

$uri = "http:///Reportserver2008/reportservice2005.asmx"

$Proxy = New-WebServiceProxy -Uri $uri -Namespace SSRS.ReportingService2005 -UseDefaultCredential ;

$Proxy | gm "SetItemDataSources"

Which returns a method definition of:

System.Void SetItemDataSources(string Item, SSRS.ReportingService2005.DataSource[] DataSources)

If I duplicate the code above, the method definition changes the second time it is requested e.g

$uri = "http:///Reportserver2008/reportservice2005.asmx"

$Proxy = New-WebServiceProxy -Uri $uri -Namespace SSRS.ReportingService2005 -UseDefaultCredential ;

$Proxy | gm "SetItemDataSources" $Proxy = New-WebServiceProxy -Uri $uri -Namespace SSRS.ReportingService2005 -UseDefaultCredential ;

$Proxy | gm "SetItemDataSources"

Returns two different method definitions:

  1. System.Void SetItemDataSources(string Item, SSRS.ReportingService2005.DataSource[] DataSources)
  2. System.Void SetItemDataSources(string Item, SSRS.ReportingService2005.DataSource[], 0juuvurk, Ve...

Can anyone explain why the definition changes??? I have tried disposing $proxy after first request, Uri does not change

I am thinking I may have to pull out $proxy and only assign it once. Any insight greatly appreciated!

Upvotes: 0

Views: 1412

Answers (1)

Start-Automating
Start-Automating

Reputation: 8367

You're right on with your instincts. Creating 2nd or 3rd proxies of web services can cause trouble, because the proxies get put into automatically generated namespaces. So proxying twice actually redoes a lot of work, and creates two very similar looking types in memory.

There are generally two ways to work with this sort of issue:

  • Use the -Namespace parameter to force the object into a namespace.
  • Use $proxy.GetType().Namespace to find the automatically generated base type

Hope this helps

Upvotes: 1

Related Questions