我在soapui有一些web服務調用。我想把它們放在一個腳本中,這樣我就可以將它們作爲監視器調用。不知道什麼是最好的選擇繼續。想寫ps腳本來做這些調用,並使用腳本作爲監視器。如果您有更好的建議,請諮詢。感謝你的幫助! - 山姆如何在需要標頭Cookie的PowerShell中製作SoapUi請求?
回答
好了,你可以發送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'
}
謝謝!我嘗試這樣做,收到此錯誤:+調用-WebRequest的' + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [調用-的WebRequest],ArgumentException的 + FullyQualifiedErrorId信息:System.ArgumentException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand –
什麼版本的PowerShell您使用的是? –
的PowerShell 3.0版 –
- 1. SOAPUI評論請求中的不需要的標記
- 2. Angular2 - 請求標頭中的Cookie
- 3. 如何更新請求頭中的cookie?
- 4. AJAX需要請求標頭嗎?
- 5. 如何在angularjs的每個請求標頭中發送cookie?
- 6. 如何在WebSocket中發佈請求標頭Cookie javascript
- 7. HttpClient請求標頭定製
- 8. SOAPUI財產轉移到請求頭
- 9. 在Django的每個請求中更改Cookie標頭值
- 10. 如何在C#中響應後獲取請求頭的Cookie#
- 11. 如何將cookie添加到HtmlUnit請求標頭?
- 12. 請求標頭和DOM中的欺騙請求標頭
- 13. 如何強制nginx在HEAD請求中包含Content-Length標頭
- 14. 如何找出請求對象中的所有請求標頭?
- 15. 如何在請求頭中獲取Cookie,同時捲曲php
- 16. IE9中的jQuery AJAX請求不發送Cookie標頭
- 17. 將標頭添加到從html內製作的http請求中
- 18. 如何從CURL php中的HTTP請求頭獲取Cookie內容?
- 19. 在請求標題中修改JSESSIONID cookie
- 20. 如何在每個請求上設置多個請求標頭
- 21. 如何設置curl的請求標頭?
- 22. 如何在curl請求中傳遞cookie
- 23. 如何在Python請求中使用cookie
- 24. 請求HTTP標頭
- 25. HTTP請求中是否允許多個Cookie標頭?
- 26. 在nativescript中複製http cookie標頭Android
- 27. 請求的操作需要提升
- 28. 如何在extjs中的ajax請求中添加授權標頭
- 29. 在SOAPUI中從json請求獲取值
- 30. 在SoapUI中並行執行請求
這是不真的很清楚你在問什麼,但你可以使用'Invoke-WebRequest'來調用Web請求。你應該能夠得到它與WCF一起工作(我認爲它是一個WCF服務,因爲你使用的是SoapUI)。 –
你有這個工作的例子嗎?我嘗試使用此cmdlet - 沒有工作。當我從soapui發出請求時,它需要cookie的標頭。如果你能提供一個有助於遵循步驟的例子。謝謝! –