New-WebServiceProxy

Create a Web service proxy object for managing the Web Service in PowerShell.

Syntax
      New-WebServiceProxy [-URI] Uri [[-Class] string]
         [[-Namespace] string] [-Credential PSCredential] [CommonParameters]

New-WebServiceProxy [-URI] Uri [[-Class] string] [[-Namespace] string] [-UseDefaultCredential] [CommonParameters] Key -Class string A name for the proxy class that the cmdlet creates for the Web service. This is used with -Namespace to provide a fully qualified name for the class. The default value is generated from the URI.

-Credential PSCredential A user account that has permission to perform this action. The default is the current user. This is an alternative to using -UseDefaultCredential.

Type a user name, such as "User64" or "Domain64\User64". Or, enter a PSCredential object, such as one generated by Get-Credential. If you type a user name, you will be prompted for a password.

-Namespace string A namespace for the new class.

The value of this parameter is used with -Class to generate a fully qualified name for the class. The default value is Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes plus a type that is generated from the URI.

The value of -Namespace may be set so that multiple Web services can be accessed with the same name.

-URI Uri
The URI of the Web service. Enter a URI or the path and file name of a file that contains a service description.

The URI must refer to an .asmx page or to a page that returns a service description. To return a service description of a Web service that was created by using ASP.NET, append "?WSDL" to the URL of the Web service (for example, http://www.ss64.com/MyWebService.asmx?WSDL).

-UseDefaultCredential Set the -UseDefaultCredential parameter in the resulting proxy object to True. This is an alternative to using the -Credential parameter. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.

New-WebServiceProxy can connect to a Web service and create a Web service proxy object in PowerShell. Use the proxy object to manage the Web service.

A Web service is an XML-based program that exchanges data over a network, particularly over the Internet. The Microsoft .NET Framework provides Web service proxy objects that represent the Web service as a .NET Framework object.

Example

Create a .NET Framework proxy of the US Zip Web service in PowerShell:

PS C:\> $zip = New-WebServiceProxy -uri http://www.webservicex.net/uszip.asmx?WSDL

or storing the URI of the Web service in a variable:

PS C:\> $URI = "http://www.webservicex.net/uszip.asmx?WSDL"
PS C:\> $zip = New-WebServiceProxy -uri $URI -namespace WebServiceProxy -class ZipClass

PS C:\> $zip | get-member -type method

TypeName: WebServiceProxy.USZip
    
    Name                      MemberType Definition
    ----                      ---------- ----------
    Abort                     Method     System.Void Abort(
    BeginGetInfoByAreaCode    Method     System.IAsyncResul
    BeginGetInfoByCity        Method     System.IAsyncResul
    BeginGetInfoByState       Method     System.IAsyncResul
    BeginGetInfoByZIP         Method     System.IAsyncResul
    CreateObjRef              Method     System.Runtime.Rem
    Discover                  Method     System.Void Discov
    Dispose                   Method     System.Void Dispos
    EndGetInfoByAreaCode      Method     System.Xml.XmlNode
    EndGetInfoByCity          Method     System.Xml.XmlNode
    EndGetInfoByState         Method     System.Xml.XmlNode
    EndGetInfoByZIP           Method     System.Xml.XmlNode
    Equals                    Method     System.Boolean Equ
    GetHashCode               Method     System.Int32 GetHa
    GetInfoByAreaCode         Method     System.Xml.XmlNode
    GetInfoByCity             Method     System.Xml.XmlNode
    GetInfoByState            Method     System.Xml.XmlNode
    GetInfoByZIP              Method     System.Xml.XmlNode...

PS C:\> $zip.getinfobyzip(20500).table
    
    CITY      : Washington
    STATE     : DC
    ZIP       : 20500
    AREA_CODE : 202
    TIME_ZONE : E

“Web users ultimately want to get at data quickly and easily. They don't care as much about attractive sites and pretty design” ~ Tim Berners-Lee

Related:

Select-XML - Find text in an XML string or document


© Copyright SS64.com 1999-2014
Some rights reserved