WebService Proxy Errors

I’m writing a script which is using the SOAP interface on secret server – when I connect I’m using:

New-WebServiceProxy -uri $url -Namespace "SecretServer" 

which allows me to call objects to work with the webservice like

$newobj = [SecretServer.Secret]::new() 

However, if I call the webservice proxy call at the beginning (to specify the web service proxy) more than once I start getting errors. If I run the script once everything will work fine but any more (e.g. debugging) I’ll get along the lines of “Cannot convert type SecretServer.Secret to type SecretServer.Secret”

I’ve been reading through this – but I’m not a C# Dev.

I’m wondering if anyone’s got some experience with webserivceproxies (ELI5 Maybe?) to help clarify this. It seems like it causes a namespace/memory issue, but I’m trying to see if there is a way to avoid this – this is going to other teams and I don’t want the whole script to break if they run it in ISE or try to mess with it. Is there possibly a way to check to see if the object exists and only run on the first instance?

Thanks for the help

submitted by /u/Risin247
[link] [comments]

Leave a Reply