New-WebServiceProxy Type Issue

Welcome Forums General PowerShell Q&A New-WebServiceProxy Type Issue

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 4 months ago.

  • Author
  • #34119

    Topics: 7
    Replies: 20
    Points: 1
    Rank: 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 ""
    $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.

  • #34120

    Topics: 9
    Replies: 2322
    Points: 0
    Rank: 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.)

  • #34121

    Topics: 7
    Replies: 20
    Points: 1
    Rank: Member

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

    Thanks =)

The topic ‘New-WebServiceProxy Type Issue’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort