PowerShell webservice查询

时间:2016-08-24 20:01:20

标签: web-services powershell soap powershell-v2.0

验证网络服务有PS script,它可以运行:

$SiteURL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?op=GetCityWeatherByZIP"

$request = [Net.HttpWebRequest]::Create($SiteURL)    
try 
{     
    #Get the response from the requst 
    $response = [Net.HttpWebResponse]$request.GetResponse() 
    Write-Host "The service is running." 
    $request.Abort() 
}     
Catch  
{ 
    Write-Warning "The service of site does not run or maybe you don't have the Credential" 
}

但是如何指定查询参数ZIP?

1 个答案:

答案 0 :(得分:1)

添加$ zip参数以获取zip作为输入

param($ zip)

在发送请求时更新您的网址以包含zip

$ SITEURL =&#34; HTTP://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP ZIP = <强> $拉链&#34;