Jas*_*ner 3 powershell web-services
我正在使用PowerShell V2并尝试查找使用Web服务代理调用异步Web方法的示例:
这是我到目前为止的代码:
$Uri = "http://localhost/mywebservice.asmx?wsdl"
$proxy = New-WebServiceProxy -Uri $Uri -UseDefaultCredential
Run Code Online (Sandbox Code Playgroud)
Web服务具有以下方法 BeginFoo EndFoo FooAsync *FooCompleted*
希望这是有道理的
这是使用BeginInvoke/EndInvoke的示例.运行$ar | Get-Member
以查看IAsyncResult对象上可用的其他方法和属性.
PS> $zip = New-WebServiceProxy -uri http://www.webservicex.net/uszip.asmx?WSDL
PS> $ar = $zip.BeginGetInfoByAreaCode("970", $null, $null)
... other PS script ...
# Now join the async work back to the PowerShell thread, wait for completion
# and grab the result. WaitOne returns false on timeout, true if signaled.
PS> $ar.AsyncWaitHandle.WaitOne([timespan]'0:0:5')
True
PS> $ar.IsCompleted
True
PS> $res = $zip.EndGetInfoByAreaCode($ar)
PS> $res.Table
CITY : Whitewater
STATE : CO
ZIP : 81527
AREA_CODE : 970
TIME_ZONE : M
CITY : Wiggins
STATE : CO
ZIP : 80654
AREA_CODE : 970
TIME_ZONE : M
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3450 次 |
最近记录: |