Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.
ebmx.s
Chrysler's e-Business Messaging Exchange (EBMX) enables the exchange of documents (typically EDI and XML) between Chrysler and their trading partners.
Robo-FTP provides all the functionality needed to implement a secure, reliable, automated connection to Chrysler EBMX using HTTPS.
While this sample script was written specifically for EBMX, the techniques demonstrated can be used for automating any HTTP POSTs.
You must first acquire the hostname, username, and password from Chrysler. You will use this information in two places:
- Configure a site called "ebmx" in the configurator and store the username and password there.
- Set the variables at the top of the file.
Once you have created the ebmx site and entered the credentials this example script will perform a loopback, uploading a file your outbox which will then be routed to your inbox, where it will be picked up and downloaded.
This script requires Robo-FTP 3.7 to function.
1 ; set username and password here and also in the Managed Site record
2 SET username = ""
3 SET password = ""
4 SET uploadRecieverID = "LOOPTEST"
5 SET uploadFileType = "LOOPBACK"
6 SET uploadFilename = "Readme.txt"
7 WORKINGDIR %installdir
8
9 FTPLOGON "ebmx" /trust=all
10
11 ;do login
12 PREPAREPOST "application/x-www-form-urlencoded"
13 POSTVALUE "function" "login"
14 POSTVALUE "username" username
15 POSTVALUE "password" password
16 SET ErrorMsg = "Could not login as " & username
17 HTTPPOST "/servlet/ebmxcontroller" "" result /intype=prepared /outtype=string
18 IFNSUBSTR result "Success!" GOTO FAILED
19
20 ;do upload
21 PREPAREPOST "multipart/form-data"
22 POSTVALUE "ReceiverId" uploadRecieverID
23 POSTVALUE "FileType" uploadFileType
24 POSTVALUE "filename" uploadFilename /file
25 SET ErrorMsg = "Could not upload " & uploadFilename
26 HTTPPOST "/servlet/ebmxcontroller?function=submitfile" "" result /intype=prepared /outtype=string
27 IFNSUBSTR result "Success!" GOTO FAILED
28
29 ;extract returned tracking id
30 SETSUBSTR depth = result " "
31 SETNUM depth = depth + 1
32 SETEXTRACT uploadedId = result " " depth
33 DISPLAY uploadedId
34
35 ;get list of files that need to be downloaded
36 PREPAREPOST "application/x-www-form-urlencoded"
37 POSTVALUE "function" "listfiles"
38 POSTVALUE "newdocsonly" "true"
39 SET ErrorMsg = "Could not get file listing"
40 HTTPPOST "/servlet/ebmxcontroller" "" "tmpfile.txt" /intype=prepared
41 IFERROR GOTO FAILED
42
43 ;discard header line
44 READFILE "tmpfile.txt" discard /termchr=lf
45
46 ;get next record from file list
47 READFILE "tmpfile.txt" record /record=next /termchr=lf /allowall
48 IFERROR GOTO FAILED ;No Records
49 ;extract tracking id from record (first item, space delimited)
50 SETEXTRACT trackingID = record " " 1
51 SET filelist = trackingID
52
53 :ADDFILE
54 READFILE "tmpfile.txt" record /record=next /termchr=lf /allowall
55 IFERROR GOTO ALLFILES ;No more Records
56 ;extract tracking id from record (first item, space delimited)
57 SETEXTRACT trackingID = record " " 1
58 SET filelist = filelist & "," & trackingID
59 GOTO ADDFILE
60 :ALLFILES
61 ;download zip file
62 PREPAREPOST "application/x-www-form-urlencoded"
63 POSTVALUE "function" "downloadfiles"
64 POSTVALUE "filelist" filelist
65 SET ErrorMsg = "Could not download " & filelist
66 HTTPPOST "/servlet/ebmxcontroller" "" "download.zip" /intype=prepared
67 IFERROR GOTO FAILED
68 ;confirm download of zip file
69 PREPAREPOST "application/x-www-form-urlencoded"
70 POSTVALUE "function" "confirmdownload"
71 POSTVALUE "filelist" filelist
72 SET ErrorMsg = "Could not confirm download of " & filelist
73 HTTPPOST "/servlet/ebmxcontroller" "" result /intype=prepared /outtype=string
74 IFERROR GOTO FAILED
75
76 GOTO DONE
77
78 :FAILED
79 DISPLAY ErrorMsg
80 DISPLAY %lasterrormsg
81 DISPLAY result
82 :DONE
83 FTPLOGOFF