嗨,我需要有适当肥皂要求的帮助。我尝试了几种方法,但没有运气。
需要生成此类肥皂请求:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><Action xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:env="http://www.w3.org/2003/05/soap-envelope" env:mustUnderstand="true"/><MessageID xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">uuid:..............</MessageID><ReplyTo xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><Address>http://www.w3.org/2004/08/addressing/anonymous</Address></ReplyTo><To xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:env="http://www.w3.org/2003/05/soap-envelope" env:mustUnderstand="true">host_url</To><wsse:Security xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" env:mustUnderstand="true"><wsse:UsernameToken><wsse:Username xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">$login</wsse:Username><wsse:Password xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" wsse:Type="http://docs.oas
is-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">$password</wsse:Password></wsse:UsernameToken></wsse:Security></soap:Header>
<soap:Body>
................
</soap:Body>
</soap:Envelope>
我坚持这个得到iis内部错误500:
(...)
write-host "Sending SOAP Request To Server: $URL"
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction","`"MethodName`"")
$soapWebRequest.ContentType = "application/soap+xml;charset=`"utf-8`";action=`"host/MethodName`""
$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 = 'host.asmx'
$soap = [xml]@"
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:flow="host">
<soap:Header/>
<soap:Body>
.....
</soap:Body>
</soap:Envelope>
"@
$ret = Execute-SOAPRequest $soap $url; $ret | Export-Clixml "test-$(Get-date -f yyyy-MM-dd-mm-ss).xml";
答案 0 :(得分:0)
您的标题似乎很奇怪,混合了您实际上不需要的转义引号。
尝试替换
$soapWebRequest.Headers.Add("SOAPAction","`"MethodName`"")
通过
$soapWebRequest.Headers.Add("SOAPAction","MethodName")
以及
$soapWebRequest.ContentType = "application/soap+xml;charset=`"utf-8`";action=`"host/MethodName`""
通过
$soapWebRequest.ContentType = "application/soap+xml; charset=utf-8";