国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PowerShell > 正文

PowerShell小技巧之執(zhí)行SOAP請求

2020-05-30 20:17:26
字體:
供稿:網(wǎng)友

SOAP的請求在Web Service是無處不在的,像WCF服務(wù)和傳統(tǒng)ASMX asp.net的web Service。如果要測試SOAP服務(wù)是否好用通過web編程來實現(xiàn)就顯得太過于復(fù)雜了,下面的腳本片段(snippet)將會輕而易舉的完成通過powershell測試和調(diào)用SOAP服務(wù):

這是一段程序代碼。

代碼如下:
function Execute-SOAPRequest
(
        [Xml]    $SOAPRequest,
        [String] $URL
)
{
        write-host "Sending SOAP Request To Server: $URL"
        $soapWebRequest = [System.Net.WebRequest]::Create($URL)
        $soapWebRequest.Headers.Add("SOAPAction","`"http://www.facilities.co.za/valid8service/valid8service/Valid8Address`"")
        $soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
        $soapWebRequest.Accept      = "text/xml"
        $soapWebRequest.Method      = "POST"
       
        write-host "Initiating Send."
        $requestStream = $soapWebRequest.GetRequestStream()
        $SOAPRequest.Save($requestStream)
        $requestStream.Close()
       
        write-host "Send Complete, Waiting For Response."
        $resp = $soapWebRequest.GetResponse()
        $responseStream = $resp.GetResponseStream()
        $soapReader = [System.IO.StreamReader]($responseStream)
        $ReturnXml = [Xml] $soapReader.ReadToEnd()
        $responseStream.Close()
       
        write-host "Response Received."
        return $ReturnXml
}
$url = 'http://www.facilities.co.za/valid8service/valid8service.asmx'
$soap = [xml]@'
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <Valid8Address xmlns="http://www.facilities.co.za/valid8service/valid8service">
      <ID>string</ID>
      <Address1></Address1>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 威宁| 洞口县| 临安市| 大埔县| 保康县| 北碚区| 镇安县| 和静县| 颍上县| 玛沁县| 呼伦贝尔市| 明溪县| 普兰店市| 霸州市| 滨州市| 邢台市| 吐鲁番市| 花莲县| 日喀则市| 易门县| 永福县| 沂水县| 桦川县| 泾川县| 元阳县| 杭州市| 开远市| 德惠市| 桂阳县| 竹山县| 平阴县| 丰城市| 株洲县| 扎囊县| 成武县| 常州市| 桓仁| 扬州市| 汉阴县| 通道| 西吉县|