-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_api.txt
More file actions
273 lines (221 loc) · 10.9 KB
/
sample_api.txt
File metadata and controls
273 lines (221 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
me.bFunction.Success = false;
me.bFunction.Failure = false;
' Set up variables to run and be garbage collected within the
' scope of this script
dim xm as String;
dim buf as String;
dim i as Integer;
dim doc as System.Xml.XmlDocument;
dim node as System.Xml.XmlNode;
dim nodeList as System.Xml.XmlNodeList;
dim ns As System.Xml.XmlNamespaceManager;
buf = me.IMESCallTypeEnum[me.IMESCallType];
'JIRA WWAS-270
dim numFields as integer;
if me.NumberOfFields > 0 then
numFields = me.NumberOfFields;
else
n umFields = me.Value.Dimension1;
endif;
'***************************************************
' Reset UDAs so the previous values don't linger
'***************************************************
me.A_status = "";
me.A_Exception = "";
me.A_StatusString = "";
me.ELCAPI_Response = "";
System.AppDomain.CurrentDomain.SetData(Me.HierarchicalName + ".ErrorMessage","");
'***************************************************
' New for MfgToolkit
'***************************************************
Dim t As System.DateTime;
t = Now();
IF me.Debug > 5 THEN LogMessage("Begin " + MethodToInvoke); ENDIF;
Dim args[1] As System.Object;
MethodToInvoke = me.MethodToInvoke;
dllLocation = me.config_ApplicationServerDLLS + me.Method_Dll;
dllInUse = me.config_ApplicationServerDLLS + me.TagName + "\" + me.Method_Dll;
'JIRA WWAS-270
url = me.API_URL; '"http://intra3.mmm.com:80/elcprintapi/services/ELCPrintAPI";
MfgToolkitNS = me.MFGToolkitNS_Enum[me.MFGToolkitNS];
IF me.Debug > 25 THEN
LogMessage("About to create new ELCAPI Instance parmaters are");
LogMessage("dllLocation = " + dllLocation);
LogMessage("dllInUse = " + dllInUse);
ENDIF;
PDMSAPI = New MMM.MFG.Toolkit.IMES.AccessDLLTest.AccessDLL(dllLocation, dllInUse);
'JIRA WWAS-200
MfgToolkitNS = PDMSAPI.myAssembly.GetType(MfgToolkitNS, False, True).FullName;
IF me.Debug > 25 THEN
LogMessage("About to create new instannce ManfgAPI Instance parmaters are");
LogMessage("MfgToolkitNS = " + MfgToolkitNS);
LogMessage("url = " + url);
ENDIF;
IF me.SentinelConnectionStr <> "" THEN
'JIRA WWAS-282
if me.debug > 0 then logmessage("Sentinel connectionstring detected"); endif;
dim parms[3] as Object;
parms[1] = System.Convert.ToString(url);
parms[2] = System.Convert.ToString(me.SentinelConnectionStr);
parms[3] = System.Convert.ToString(me.SentinelLabelPath);
PDMSAPI.CreateNewInstance(MfgToolkitNS ,parms);
ELSE
'JIRA WWAS-282
PDMSAPI.CreateNewInstance(MfgToolkitNS ,url);
ENDIF;
If (NULL == PDMSAPI.myInstance) or (PDMSAPI.BasicErrorHand.Msg <> NULL) Then
If StringLen(PDMSAPI.BasicErrorHand.Msg) > 0 Then
LogMessage("***********************************************************************");
LogMessage("API Request Failure - Bad Namespace or dll (PDMSAPI)");
LogMessage(PDMSAPI.BasicErrorHand.Msg);
LogMessage("***********************************************************************");
System.AppDomain.CurrentDomain.SetData(Me.HierarchicalName + ".ErrorMessage",PDMSAPI.BasicErrorHand.Msg);
EndIf;
EndIf;
IF me.Debug > 25 THEN LogMessage("Created PDMSAPI Instance"); ENDIF;
'***************************************************
' TEMPLATE WORK: SET THESE - per UDAs
'***************************************************
'***************************************************
' Special for ELC MfgToolkit Functions - set these!
'***************************************************
Dim reqStr as string;
' To send the correct xml - the type has to be determined
' doc types for laserjet forms
' gs types for labels
'JIRA WWAS-111 label type and MMM_ID_nbr needs to be set by adapter.
'If StringInString(me.FormatName, "Load Ticket", 1, 0 ) > 0 Then
' me.RequestType = "doc";
'Else
' me.RequestType = "gs";
' me.MMM_Id_Nbr = MyContainer.GetLoadDetails.P_mmm_id_nbr[1];
'Endif;
If me.RequestType == "gs" Then
reqStr = "<?xml version=""1.0""?>";
reqStr = reqStr + "<apiRequest><" + me.RequestType + "Request>";
reqStr = reqStr + "<mmmId>" + me.MMM_Id_Nbr + "</mmmId>";
reqStr = reqStr + "<request>";
reqStr = reqStr + "<facilityName>" + me.FacilityCode + "</facilityName>";
reqStr = reqStr + "<workCenterCode>" + me.WorkCenterCode + "</workCenterCode>";
reqStr = reqStr + "<formatName>" + me.FormatName + "</formatName>";
reqStr = reqStr + "<copies>" + me.Copies + "</copies>";
reqStr = reqStr + "<printerName>" + me.PrinterName + "</printerName>";
reqStr = reqStr + "<preferenceName>" + me.PreferenceName + "</preferenceName>";
Endif;
If me.RequestType == "doc" Then
reqStr = "<?xml version=""1.0""?>";
reqStr = reqStr + "<apiRequest><" + me.RequestType + "Request>";
reqStr = reqStr + "<request>";
reqStr = reqStr + "<facilityName>" + me.FacilityCode + "</facilityName>";
reqStr = reqStr + "<workCenterCode>" + me.WorkCenterCode + "</workCenterCode>";
reqStr = reqStr + "<formatName>" + me.FormatName + "</formatName>";
reqStr = reqStr + "<copies>" + me.Copies + "</copies>";
reqStr = reqStr + "<printerName>" + me.PrinterName + "</printerName>";
reqStr = reqStr + "<preferenceName>" + me.PreferenceName + "</preferenceName>";
Endif;
'JIRA WWAS-270
For i = 1 to numFields 'me.Value.Dimension1
IF StringLen(me.Value[i]) > 0 THEN
IF me.Debug > 25 THEN LogMessage(me.Name[i] + " = " + me.Value[i]); ENDIF;
reqStr = reqStr + "<field name=""" + me.Name[i] + """ value=""" + StringUpper(me.Value[i]) + """></field>";
ENDIF;
Next;
reqStr = reqStr + "</request></" + me.RequestType + "Request></apiRequest>";
'****************************************************************
' Below is a functional request string that will work for testing
'reqStr = "<?xml version=""1.0""?><apiRequest><docRequest><request><facilityName>H5</facilityName><workCenterCode>Office Testing</workCenterCode><formatName>TSSD Load Ticket</formatName><copies>1</copies><printerName>IT 8150DN</printerName><preferenceName>TSSD Load Ticket</preferenceName><field name=""LOAD_ID"" value=""12324"" /><field name=""BATCH_NBR"" value=""4344"" /><field name=""UNIT_NBR"" value=""0001"" /><field name=""RUN_NBR"" value=""9999"" /><field name=""INVENTORY_QTY"" value=""1"" /><field name=""INVENTORY_UOM"" value=""EA"" /><field name=""MMM_FACILITY_CODE"" value=""H5"" /><field name=""MFG_ORDER_NBR"" value=""M24552"" /><field name=""ITEM_DESC"" value=""Ricks Test Part"" /><field name=""CREATE_DATETIME"" value=""10/02/09"" /><field name=""MMM_ID_NBR"" value=""12345678901"" /><field name=""REPORTING_QTY"" value=""1"" /><field name=""REPORTING_UOM"" value=""EA"" /></request></docRequest></apiRequest>";
'****************************************************************
' log the xml request
LogMessage(reqStr);
'The Response:
IF me.config_ResponseAsString == False THEN
logmessage("config_ResponseAsString needs to be set to true");
me.bFunction.Failure = true;
ELSE
'Response As string
myargs[1] = reqStr;
ResponseString = PDMSAPI.InvokemyMethod(MethodToInvoke , myargs);
IF PDMSAPI.BasicErrorHand.Msg == NULL THEN
LogMessage(ResponseString );
xm = ResponseString;
'logmessage(xm);
'***************************************************
' Perform the Post Processing
'***************************************************
buf = "mesapi/schemas/version1.0/" + buf + "response";
doc = new System.Xml.XmlDocument();
' NO NEED FOR A NAMESPACE WITH ELC WEB SERVICE
'ns = new System.Xml.XmlNamespaceManager(doc.NameTable);
'ns.AddNamespace("http://webservice.printapi.elc.mmm.com", buf);
doc.LoadXML(xm);
'***************************************************
' All P_ and A_ UDAs should be set here from XML
'***************************************************
' *** ATTRIBUTE VALUES ***
' If UDA begins with 'A_' search response XML for 'success_ind' type attributes
nodeList = doc.SelectNodes("//status", ns); 'apiResponse/result/
For Each node in nodeList
'me.A_Status = node.InnerText;
me.A_StatusString = node.InnerText;
IF me.A_StatusString == "success" THEN 'Response is either "success" or "failed"
me.A_Status = TRUE;
ELSE
me.A_Status = FALSE;
ENDIF;
Next;
logmessage("Status = " + me.A_StatusString);
me.ELCAPI_Response = stringleft(ResponseString,1000);
logmessage("ResponseString= " + ResponseString);
logmessage("me.ELCAPI_Response= " + me.ELCAPI_Response );
' *** ATTRIBUTE VALUES ***
' If UDA begins with 'A_' search response XML for 'success_ind' type attributes
nodeList = doc.SelectNodes("//exception", ns); 'apiResponse/result/
For Each node in nodeList
me.A_Exception = node.InnerText;
Next;
logmessage("Exception = " + me.A_Exception);
'***************************************************
' Reset the request UDAs
'***************************************************
' Special UDAs to set for ELC print function
' get from IMES SPROC function ItemMaster Extended Columns
If me.Debug < 25 Then
me.FormatName = "";
me.Copies = 1;
me.PrinterName = "";
me.PreferenceName = "";
me.FacilityCode = "";
me.WorkCenterCode = "";
'JIRA WWAS-111 DSC 03/30/2011 reset MMM_Id_Nbr (needs to be set by adapter)
me.MMM_Id_Nbr = "";
' Clear old responses
For i = 1 to me.Value.Dimension1
me.Value[i] = "";
Next;
Endif;
ELSE
logmessage("Request Failure");
me.bFunction.Failure = True;
ENDIF;
ENDIF;
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Checking for Errors
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
IF PDMSAPI.BasicErrorHand.Msg <> NULL THEN
me.bFunction.Failure = True;
If StringLen(PDMSAPI.BasicErrorHand.Msg) > 0 Then
LogMessage("***********************************************************************");
LogMessage("API Request Failure");
LogMessage(PDMSAPI.BasicErrorHand.Msg);
LogMessage("***********************************************************************");
System.AppDomain.CurrentDomain.SetData(Me.HierarchicalName + ".ErrorMessage",PDMSAPI.BasicErrorHand.Msg);
'Create PDMS Service Request on failure if configured to do so.''''''''''''''''''
LogMessage("API Request Failed, Creating a Request");
IF me.config_WriteToEventLogger == True THEN
PDMSAPI.BasicErrorHand.WriteToEventLogger();
ENDIF;
ENDIF;
ELSE
me.bFunction.Success = True;
ENDIF;
LogMessage("IMES " + me.IMESCallTypeEnum[me.IMESCallType] + " call completed");