【发布时间】:2018-07-06 12:32:25
【问题描述】:
第一次使用 PS,第一次写脚本!
我有一个 wsdl 本地存储在我的主机上,它指向一个 localhost 端点。这是必要的,因为远程服务器不为 wsdl 提供服务。但是,它们是这些 SOAP 请求的有效端点。
我的网络中有多个端点,我想在引用静态 wsdl 的同时向每个端点发送 New-WebServiceProxy 请求。有没有办法使用本地 wsdl,但指定一个目标端点覆盖?
这是我目前拥有的(请原谅 cmets,我正在努力学习):
# The uri refers to the wsdl page
$uri = ( Join-Path $PSScriptRoot "\wsdl\PublicService.wsdl" )
# Create the Web Service Proxy
$service = New-WebServiceProxy -Uri $uri -Namespace WebServiceProxy -UseDefaultCredential -Verbose
# Specify the list of target servers IP addressesr hostnames
$serverlistpath = ( Join-Path $PSScriptRoot "\servers\servers.txt" )
$servers = gc $serverlistpath
# Create an output path to the templates folderr use witin the SOAP request
$templatetemp = ( Join-Path $PSScriptRoot "\template_temp\" )
# Gets the UNC path of the script running location
$currentDirectory = Get-Location
$currentDrive = Split-Path -qualifier $currentDirectory.Path
$logicalDisk = Gwmi Win32_LogicalDisk -filter "DriveType = 4 AND DeviceID = '$currentDrive'"
$uncPath = $currentDirectory.Path.Replace($currentDrive, $logicalDisk.ProviderName)
# Execute SOAP request
$service.Backup("false", "true", "false", "false", "$uncpath\template_temp")
我计划在 servers.txt 中将其作为 ForEach 循环运行,但每次都需要能够在指向静态 wsdl 的同时设置不同的 URL。每个服务器本身并不为 wsdl 提供服务。
任何建议表示赞赏。
【问题讨论】:
标签: powershell soap new-webserviceproxy