New-WebServiceProxy Type Issue

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Deadly-Bagel Deadly-Bagel 8 months, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #34119
    Profile photo of Deadly-Bagel

    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 ""
    $cproxy.CheckInstallationIdV2($installcode, [ref]$company, [ref]$dnsadd, [ref]$null, [ref]$null, [ref]$null)
    $bproxy = New-WebServiceProxy -Uri -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.

    Profile photo of Dave Wyatt
    Dave Wyatt

    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.)

    Profile photo of Deadly-Bagel

    Ahhhh because it's using the same namespace as the original proxy which of course then doesn't include the class I need.

    Thanks =)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.