我正在使用 PowerShell V2 并试图找到一个使用 Web 服务代理来调用异步 Web 方法的示例:
这是我到目前为止的代码:
$Uri = "http://localhost/mywebservice.asmx?wsdl"
$proxy = New-WebServiceProxy -Uri $Uri -UseDefaultCredential
Web 服务具有以下方法 BeginFoo EndFoo FooAsync * FooCompleted *
希望这是有道理的
我正在使用 PowerShell V2 并试图找到一个使用 Web 服务代理来调用异步 Web 方法的示例:
这是我到目前为止的代码:
$Uri = "http://localhost/mywebservice.asmx?wsdl"
$proxy = New-WebServiceProxy -Uri $Uri -UseDefaultCredential
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