使用PowerShell访问SOAP Web服务

时间:2018-02-16 19:12:01

标签: .net web-services powershell soap wsdl

Microsoft suggests致电webservicex,但他们seem已关闭。

Google似乎已经放弃了SOAP。

可能有一个现有的带有WSDL规范的SOAP服务可以从powershell中使用吗?

1 个答案:

答案 0 :(得分:1)

http://www.webservicex.net完美无缺。

这是一个例子:

(New-Object System.Net.WebClient).Proxy.Credentials =  [System.Net.CredentialCache]::DefaultNetworkCredentials
$url = "http://www.webservicex.net/globalweather.asmx?wsdl"
$webservicex = New-WebServiceProxy -Uri $url -namespace WebServiceProxy -Class GlobalWeatherSoap

$webservicex.GetCitiesByCountry("Netherlands")

响应:

<NewDataSet>
  <Table>
    <Country>Netherlands</Country>
    <City>Amsterdam Airport Schiphol</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Maastricht Airport Zuid Limburg</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>De Bilt</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Deelen</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Eindhoven</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Groningen Airport Eelde</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Gilze-Rijen</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>De Kooy</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Leeuwarden</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Rotterdam Airport Zestienhoven</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Soesterberg</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Twenthe</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Valkenburg</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Volkel</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Vlieland</City>
  </Table>
  <Table>
    <Country>Netherlands</Country>
    <City>Woensdrecht</City>
  </Table>
  <Table>
    <Country>Netherlands Antilles</Country>
    <City>Flamingo Airport, Bonaire</City>
  </Table>
  <Table>
    <Country>Netherlands Antilles</Country>
    <City>Hato Airport, Curacao</City>
  </Table>
  <Table>
    <Country>Netherlands Antilles</Country>
    <City>Roosevelt Airport Saint Eustatius</City>
  </Table>
  <Table>
    <Country>Netherlands Antilles</Country>
    <City>Juliana Airport, Saint Maarten</City>
  </Table>
</NewDataSet>