This topic contains 2 replies, has 2 voices, and was last updated by
January 21, 2016 at 6:48 am #34119ParticipantTopics: 7Replies: 20Points: 1Rank: Member
I have a script that connects to a web service to retrieve customer details for use in configuring a server. Later on in the script it connects to a BITS service to obtain installation files.
Both use New-WebServiceProxy and [ref] variables to export the data:
$cproxy = New-WebServiceProxy -Uri "http://first.domain.com/clientupdatewebservice.asmx" $cproxy.CheckInstallationIdV2($installcode, [ref]$company, [ref]$dnsadd, [ref]$null, [ref]$null, [ref]$null) ... $bproxy = New-WebServiceProxy -Uri http://second.domain.com/rmsdownloadservice.asmx -Credential $cred $bits = New-Object -Type Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1ms_com_downloadservice_asmx.Directory $bproxy.GetLatestVersionDetails([ref]$bits) | Out-Null
This has been running perfectly fine until today, which I now realise is because currently there is no restart between the two sections while previously there was. The error I'm getting is that the type for $bits cannot be found.
If I run the two individually it's fine, but once the first proxy is created I can't create the object for $bits (nor does it want to accept anything like PSObject or Object or whatever, it has to be the exact type AFAIK). Disposing the original proxy doesn't help either.
January 21, 2016 at 7:07 am #34120MemberTopics: 9Replies: 2322Points: 0Rank: Member
New-WebServiceProxy has a -Namespace parameter that you can use to control these conflicts. (Your type names passed to New-Object will also change slightly to match the Namespace you've specified.)
January 21, 2016 at 7:20 am #34121ParticipantTopics: 7Replies: 20Points: 1Rank: Member
Ahhhh because it's using the same namespace as the original proxy which of course then doesn't include the class I need.
The topic ‘New-WebServiceProxy Type Issue’ is closed to new replies.