New-WebServiceProxy

The New-WebServiceProxy command is used to connect to a SOAP web service. This can be a service endpoint, such as a .NET service.asmx URL, or a WSDL document.

New-WebServiceProxy and PowerShell Core

The New-WebServiceProxy command has not been implemented in PowerShell Core. The examples in this section only apply when using Windows PowerShell.

The web service will include methods, and may also include other object types and enumerations.

The command accesses a service anonymously by default. If the current user should be passed on, the UseDefaultCredential parameter should be used. If explicit credentials are required, the Credential parameter can be used.

Localhost and a port

Throughout this section, localhost and a port are used to connect to the web service. The port is set by Visual Studio when debugging the simple SOAP web service and must be updated to use these examples.

By default, New-WebServiceProxy creates as dynamic namespace. This is as follows:

PS> $params = @{
>> Uri = 'http://localhost:62369/Service.asmx'
>> }
>> $service = New-WebServiceProxy @params
>> $service.GetType().Namespace
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy4__localhost_62369_Service_asmx

The dynamic namespace is useful as it avoids problems when multiple connections are made to the same service in the same session.

To simplify exploring the web service in, a fixed namespace might be defined:

$params = @{
Uri = 'http://localhost:62369/Service.asmx'
Namespace = 'SOAP'
}
$service = New-WebServiceProxy @params

The service object returned by New-WebServiceProxy describes the URL used to connect, the timeout, the HTTP user agent, and so on. The object is also the starting point for exploring the interface; it is used to expose web services methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.140.206