다음 powershell 스크립트를 사용하여 텍스트 파일 (soap.txt)에 저장된 xml 데이터를 끝점으로 보내고 있습니다. 위의 방법은 잘 작동하는 동안Powershell : Invoke-WebRequest
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("charset", 'utf-8')
$headers.Add("SOAPAction", 'nms:rtEvent#PushEvent')
Invoke-WebRequest http://localhost:8080/nl/jsp/soaprouter.jsp -Method Post -ContentType 'text/xml' -Headers $headers -InFile D:\Scripts\archive\soap.txt
가, 내가 내용을 풍부하게 할 수 있도록하는 대신 몸 PARAM를 사용하고자하지만 몇 가지 문제에 직면하고, 아래의 코드입니다.
## Set SOAP headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("charset", 'utf-8')
$headers.Add("SOAPAction", 'nms:rtEvent#PushEvent')
$url = "http://localhost:8080/nl/jsp/soaprouter.jsp"
$body = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:nms:rtEvent">
<soapenv:Header/>
<soapenv:Body>
...etc etc
</soapenv:Body>
</soapenv:Envelope>'
Invoke-WebRequest -Method Post -Uri $url -Headers $headers -Body $body -ContentType 'application/xml'
나는 다음과 같은 오류
을 얻고 나는 또한
$body = @"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:nms:rtEvent">
<soapenv:Header/>
<soapenv:Body>
...rest of code here asd
</soapenv:Body>
</soapenv:Envelope>
"@
Invoke-WebRequest -Method Post -Uri $url -ContentType 'text/xml' -Headers $headers -Body $body
을 시도했습니다 그리고 내가 헤더가 appropiate 속성 또는 메서드를 사용하여 수정되어야 함을 얻을, 그래서 또한 헤더에 콘텐츠 유형을 추가하지만 그 중 하나가 작동하지 않습니다, 나는 powershell 3.0을 사용하고 있습니다
당신은 infile에서 전달하는 내용을 공유해주십시오. –
@RanadipDutta는 본질적으로 $ body 변수에 정의 된 내용과 동일하지만 기밀 정보, 간단한 xml SOAP –
Fine을 삭제했습니다. 내가 그걸 통해 가서 샘플을 만들어 보자. –