Siebel EAI > VBS file to test Sending and Receiving XML files in Siebel
Testing sending and receiving XML files using VBScript
We initially had an issue about testing EAI files. It was hard to either send any or receive any files. My colleague wrote a nice script that can be used from any command prompt in Windows. We have tried this against Siebel 8.1 You do need to have an input file, if the file is not formatted correctly, you will get an error message. How to create a correct XML file will be explained in another article.
Name the file something.vbs and run it from cmd prompt The input file and output file should be in the same folder as this script. The input file should be called in.xml. The output file will be out.xml
'---------------------------------------- 'SendXML 'ver. 0.3 ' 'Author: Karel Vítek ' 'Description: ' Send [./in.xml] and retrieve [./out.xml] SOAP message from a server [URL hardcoded]. 'Limitations: ' Head pattern: "<SOAP-?ENV:Body>\s*<ns[0-9]:(\w+)_Input\s+xmlns:ns[0-9]=""(.+)"">" ' in.XML MUST BE VALID! No checking is done. ' ' Tested on Employee interface ONLY! '----------------------------------------
OPTION EXPLICIT
'-Verbose-mode-0-1----------------------- Const VERBOSE = 1 '----------------------------------------
Dim FSO, oInFile, sURL, sSOAHead, sRequest, sResponse
'-Add-URL-here---------------------------
'-- please change the value siebelurl with the correct ip address/url address '-- if you are using eai in a non english object manager, please change the string '-- eai_enu to the correct object manager value
sURL = "http://siebelurl/eai_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&WSSOAP=1&UserName=wsarmuser&Password=wsarmuser123"
'----------------------------------------
Set FSO = CreateObject("Scripting.FileSystemObject") Set oInFile = FSO.OpenTextFile("in.xml", 1) 'for reading
sRequest = oInFile.ReadAll oInFile.Close
If VERBOSE Then Wscript.Echo "URL:" & vbNewLine & sURL & vbNewLine If VERBOSE Then Wscript.Echo "Sending request:" & vbNewLine & sRequest & vbNewLine
If VERBOSE Then Wscript.Echo "Heather:" & vbNewLine sSOAHead = GetSOAHead(sRequest) If VERBOSE Then Wscript.Echo sSOAHead & vbNewLine
sResponse = GetXML(sRequest,sURL, sSOAHead) If VERBOSE Then Wscript.Echo "Server response: " & vbNewLine & sResponse & vbNewLine
SaveFile sResponse, "out.xml"
Function GetXML(sSendXML, sURL, sSOAHead) Dim oXMLHTTP Dim sXMLResponse
Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP") oXMLHTTP.Open "POST", sURL, false oXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8" oXMLHTTP.setRequestHeader "SOAPAction", sSOAHead
'oXMLHTTP.setRequestHeader "User-Agent", "Jakarta Commons-HttpClient/3.1" 'oXMLHTTP.setRequestHeader "Host", "10.152.178.196" 'target srvr 'oXMLHTTP.setRequestHeader "Content-Length", "567" On Error Resume Next oXMLHTTP.send sSendXML sXMLResponse = oXMLHTTP.responseText
If Err.Number = 0 Then GetXML = sXMLResponse Else GetXML = Err.Number & ": " & Err.Description End If On Error Goto 0
Set oXMLHTTP = Nothing End Function
Sub SaveFile (sText, sFile) Dim oStream Set oStream = CreateObject("ADODB.Stream") With oStream .Open .CharSet = "utf-8" .WriteText sText .SaveToFile sFile, 2 End With Set oStream = Nothing End Sub
Function GetSOAHead(sXML) Dim HEAD_PATTRN Dim regEx, colMatches Dim Match, sMethod, sNamespace Set regEx = New RegExp HEAD_PATTRN = "<SOAP-?ENV:Body>\s*<ns[0-9]:(\w+)_Input\s+xmlns:ns[0-9]=""(.+)"">" regEx.Pattern = HEAD_PATTRN regEx.IgnoreCase = True regEx.Global = False regEx.MultiLine = True Set colMatches = regEx.Execute(sXML) If colMatches.Count = 0 Then GetSOAHead = 0 Exit Function End If 'Wscript.Echo colMatches(0).Value sMethod = colMatches(0).SubMatches.Item(0) 'get the first occurance sNamespace = colMatches(0).SubMatches.Item(1) GetSOAHead = """document/" & sNamespace & ":" & sMethod & """" End Function
|