我在soapui中有一些网络服务电话。我想把它们放在一个脚本中,这样我就可以将它们作为监视器调用。不确定什么是最好的选择。考虑编写ps脚本来进行这些调用并使用脚本作为监视器。如果你有更好的建议,请告知。感谢您的帮助! - 山姆
答案 0 :(得分:0)
好吧,你可以像这样发送一个SOAP请求:
$soap = @"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Geocode xmlns="http://dev.virtualearth.net/webservices/v1/geocode/contracts">
<request xmlns:a="http://dev.virtualearth.net/webservices/v1/geocode" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Credentials xmlns="http://dev.virtualearth.net/webservices/v1/common">
<ApplicationId>ThisIsMySecret</ApplicationId>
<Token i:nil="true" />
</Credentials>
<Culture xmlns="http://dev.virtualearth.net/webservices/v1/common" i:nil="true" />
<ExecutionOptions xmlns="http://dev.virtualearth.net/webservices/v1/common" i:nil="true" />
<UserProfile xmlns="http://dev.virtualearth.net/webservices/v1/common" i:nil="true" />
<a:Address xmlns:b="http://dev.virtualearth.net/webservices/v1/common">
<b:AddressLine>1747 Reynolds St NW</b:AddressLine>
<b:AdminDistrict>TN</b:AdminDistrict>
<b:CountryRegion i:nil="true" />
<b:District i:nil="true" />
<b:FormattedAddress i:nil="true" />
<b:Locality>Knoxville</b:Locality>
<b:PostalCode>37921</b:PostalCode>
<b:PostalTown i:nil="true" />
</a:Address>
<a:Options i:nil="true" />
<a:Query i:nil="true" />
</request>
</Geocode>
</s:Body>
</s:Envelope>
"@
$headers = @{
'Content-Type' = 'text/xml; charset=utf-8';
'SOAPAction' = 'http://dev.virtualearth.net/webservices/v1/geocode/contracts/IGeocodeService/Geocode'
}
Invoke-WebRequest `
-Uri http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc `
-Body $soap `
-Method Post `
-Headers $headers
如果您需要添加Cookie,只需将字符串添加到$headers
:
$headers = @{
'Content-Type' = 'text/xml; charset=utf-8';
'SOAPAction' = 'http://dev.virtualearth.net/webservices/v1/geocode/contracts/IGeocodeService/Geocode';
'Cookie' = 'YouCookieGoesHere'
}