VBS : XML WEBSERVICE: SOAP REQUEST
'usage: soap_request.vbs /usr:<UserName>
Dim colNamedArguments : Set colNamedArguments = WScript.Arguments.Named
Const ForReading = 1, ForWriting = 2, ForAppending = 8
VbsPath = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\"))
UsrName = colNamedArguments.Item("usr")
'-- Constants you can modify
Const clogin= "ou=<login>,ou=xxx,dc=xxx,dc=xxx"
Const cpassword = "<password>"
Const cWebserviceUri = " http://<Certificate Webservice URL> "
Const cFolderNameForCert = "TemporyCertFile\"
Const cFolderNameForXmlWebservice = "TemporyXmlWebServiceFile\"
Const LogFileNameAction = "LogsAction"
dim xmlnsurl : xmlnsurl = "http://<Webservice URL>"
Dim messageSoap,xmlHttp,fso,WriteXmlCertificate
wscript.echo "Xml Webservice Response For" & UsrName & " = " & xmlresponse(UsrName)
function xmlresponse(UsrName)
messageSoap = "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""><s:Body
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><getPersonCertificatesByUserName xmlns=" & chr(34) & xmlnsurl & chr(34) & ">" _
& "<login>" & clogin & "</login><password>"& cpassword & "</password><UserName>"& UsrName &
"</UserName></getPersonCertificatesByUserName></s:Body></s:Envelope>"
Set xmlHttp = CreateObject("MSXML2.XMLHTTP.3.0")
xmlhttp.open "POST", cWebserviceUri , False
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.setRequestHeader "SOAPAction ",""""""
xmlhttp.send messageSoap
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(VbsPath & cFolderNameForXmlWebservice) Then
fso.CreateFolder(VbsPath & cFolderNameForXmlWebservice)
If cBoolDebug = True Then
wscript.echo "Create Sub folder for xml webservice file"
End If
End If
wscript.Echo "webservice answer = " & xmlhttp.responseXML.xml
wscript.echo "Create XML for user : " & UsrName
Dim WriteXmlCertificate : Set WriteXmlCertificate = fso.OpenTextFile(VbsPath & cFolderNameForXmlWebservice & UsrName & ".xml", 2, True)
WriteXmlCertificate.WriteLine(xmlhttp.responseXML.xml)
WriteXmlCertificate.Close
UserUserNameProcessing = UsrName
xmlresponse = xmlhttp.responseXML.xml
Set WriteXmlCertificate = Nothing
Set fso = Nothing
Set xmlHttp = Nothing
end function
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article