我在soapui中有一些web服务调用。我想把它们放在一个脚本中,这样我就可以把它们作为监视器调用。不确定什么是继续进行的最佳选择。正在考虑编写ps脚本来进行这些调用,并使用该脚本作为监视器。如果你有更好的建议,请提供建议。感谢你的帮助!-Sam
好吧,您可以发送这样的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'
}