C_mdsrvBusRequest.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** IBM Cognos Products: mdsrv
  5. **
  6. ** (C) Copyright IBM Corp. 2008, 2010
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *****************************************************************/
  10. /**
  11. * This class allows for the sending of an async request to the Cognos BI Bus.
  12. *
  13. * @constructor
  14. * @extends C_SoapRequest
  15. * @extends I_ServerPromptingListener
  16. * @extends I_ServerLogonListener
  17. * @requires G_BusServer
  18. * @requires C_Error
  19. * @param {I_RequestListener} v_oListener The listener for this request. If null, then no events will be fired.
  20. * @param {String} v_sSOAPAction SOAP action to set in the request header
  21. * @param {String} v_sRequest Request to send in SOAP body
  22. */
  23. function C_mdsrvBusRequest( v_oListener, v_sSOAPAction, v_sRequest )
  24. {
  25. this.F_ConstructBaseClass( v_oListener, G_CCHL.M_sGatewayURL, v_sSOAPAction );
  26. /**
  27. * @private
  28. */
  29. this.m_sRequest = v_sRequest;
  30. /**
  31. * @private
  32. */
  33. this.m_sRequestSoapAction = v_sSOAPAction;
  34. /**
  35. * @private
  36. */
  37. this.m_docResponse = null;
  38. /**
  39. * @private
  40. */
  41. this.m_bProcessResponse = true;
  42. /**
  43. * @private
  44. */
  45. this.m_bServerPrompting = true;
  46. /**
  47. * @private
  48. */
  49. this.m_sPromptReport = "";
  50. /**
  51. * @private
  52. */
  53. this.m_bAsyncBusRequest = false;
  54. /**
  55. * @private
  56. */
  57. this.m_sRoutingServerGroup = null;
  58. /**
  59. * @private
  60. */
  61. this.m_bIsLoggingOn = false;
  62. /**
  63. * @private
  64. */
  65. this.m_bIsPrompting = false;
  66. /**
  67. * @private
  68. */
  69. this.m_sFollowOnRequestSOAPAction = C_mdsrvBusRequest.K_sSOAPAction_metadataService_absolute;
  70. /**
  71. * @private
  72. */
  73. this.m_sCancelRequestSOAPAction = C_mdsrvBusRequest.K_sSOAPAction_metadataService_control;
  74. /**
  75. * @private
  76. */
  77. this.m_aNamespaces = [];
  78. this.F_AddNamespace( C_mdsrvBusRequest.k_sBIBusNamespaceDecl );
  79. this.F_AddNamespace( C_mdsrvBusRequest.k_sBIBusMDNamespaceDecl );
  80. };
  81. C_mdsrvBusRequest.F_Extends( C_SoapRequest );
  82. /**
  83. * Primary Wait Threshold to use for async requests
  84. * @type Integer
  85. */
  86. C_mdsrvBusRequest.K_sPrimaryWaitThreshold = 50;
  87. /**
  88. * Secondary Wait Threshold to use for async requests
  89. * @type Integer
  90. */
  91. C_mdsrvBusRequest.K_sSecondaryWaitThreshold = 30;
  92. /**
  93. * @private
  94. */
  95. C_mdsrvBusRequest.m_sLastRequest = "";
  96. /**
  97. * @private
  98. */
  99. C_mdsrvBusRequest.m_sLastResponse = "";
  100. /**
  101. * Holds the available bus tracking info available for a new request. Only one request at a
  102. * time can be using a given bus:tracking
  103. *
  104. * @private
  105. */
  106. C_mdsrvBusRequest.m_aBusTracking = [];
  107. /**
  108. * @returns The last SOAP request sent to the server.
  109. * @type String
  110. */
  111. C_mdsrvBusRequest.F_GetLastRequest = function()
  112. {
  113. return this.m_sLastRequest;
  114. };
  115. /**
  116. * @returns The last SOAP response returned by the server.
  117. * @type XMLDocument
  118. */
  119. C_mdsrvBusRequest.F_GetLastResponse = function()
  120. {
  121. return this.m_sLastResponse;
  122. };
  123. /**
  124. * Releases all current conversations being maintained with the server thereby allowing the server
  125. * to free the resources asssociated with them.
  126. * @type void
  127. */
  128. C_mdsrvBusRequest.F_ReleaseAllTracking = function()
  129. {
  130. // This method will only release reportService conversations. A more general approach will be
  131. // needed in the future to release the requests associated with each service.
  132. // We will need to have global objects to manage the requests RS makes to each service so that the
  133. // conversations, and async activity can be managed properly.
  134. // I have logged " 593994 0 BUS requests are not managed properly" to track this
  135. var v_iRequests = this.m_aBusTracking.length;
  136. var v_sReleaseRequest =
  137. "<rns1:release>" +
  138. '<bus:conversation xsi:type="bus:asynchRequest">' +
  139. '</bus:conversation>' +
  140. "</rns1:release>";
  141. // release each bus request being maintained
  142. for (var i = 0; i < v_iRequests; ++i)
  143. {
  144. var v_oReleaseRequest = new C_mdsrvBusRequest( null, C_mdsrvBusRequest.K_sSOAPAction_metadataService_control, v_sReleaseRequest );
  145. // Requests must be synchronous because they typically happen when the browser is shutting down. We abort all active requests when
  146. // shutting down the browser to ensure it goes down cleanly, so if these requests are async, they will be aborted before the server
  147. // gets them.
  148. v_oReleaseRequest.m_bAsync = false;
  149. v_oReleaseRequest.F_Send();
  150. }
  151. };
  152. /**
  153. * @returns The request SOAP response
  154. * @type XMLDocument
  155. */
  156. C_mdsrvBusRequest.prototype.F_GetResponse = function()
  157. {
  158. return this.m_docResponse;
  159. };
  160. /**
  161. * @returns True if the prompt window is up
  162. * @type Boolean
  163. */
  164. C_mdsrvBusRequest.prototype.F_IsPrompting = function()
  165. {
  166. return this.m_bIsPrompting;
  167. };
  168. /**
  169. * @returns True if the logon window is up
  170. * @type Boolean
  171. */
  172. C_mdsrvBusRequest.prototype.F_IsLoggingOn = function()
  173. {
  174. return this.m_bIsLoggingOn;
  175. };
  176. /**
  177. * Overrides the default CCHL locales for this request.
  178. * @param {String} v_sProductLocale Product locale.
  179. * @param {String} v_sContentLocale Content locale.
  180. * @type void
  181. */
  182. C_mdsrvBusRequest.prototype.F_SetLocale = function(v_sProductLocale, v_sContentLocale)
  183. {
  184. this.m_sProductLocale = v_sProductLocale;
  185. this.m_sContentLocale = v_sContentLocale;
  186. };
  187. /**
  188. * The response for the request will not be processed and checked for any errors or server interaction
  189. * @type void
  190. */
  191. C_mdsrvBusRequest.prototype.F_SetNoResponseProcessing = function()
  192. {
  193. this.m_bProcessResponse = false;
  194. };
  195. /**
  196. * Sets the request to not do server prompting.
  197. * @type void
  198. */
  199. C_mdsrvBusRequest.prototype.F_SetNoServerPrompting = function()
  200. {
  201. this.m_bServerPrompting = false;
  202. };
  203. /**
  204. * Sets the routing server group to use for this request.
  205. * @type void
  206. */
  207. C_mdsrvBusRequest.prototype.F_SetRoutingServerGroup = function(v_sRoutingServerGroup)
  208. {
  209. this.m_sRoutingServerGroup = v_sRoutingServerGroup;
  210. };
  211. /**
  212. * Sets the request to follow the BI Bus asynchronous mechanism
  213. * @type void
  214. */
  215. C_mdsrvBusRequest.prototype.F_SetAsyncBusRequest = function(v_sWaitMethod, v_sCancelMethod, v_sGetOutputMethod, v_sFollowOnRequestSOAPAction, v_sCancelRequestSOAPAction)
  216. {
  217. this.m_bAsyncBusRequest = true;
  218. this.m_sWaitMethod = v_sWaitMethod;
  219. this.m_sCancelMethod = v_sCancelMethod;
  220. this.m_sGetOutputMethod = v_sGetOutputMethod;
  221. this.m_sFollowOnRequestSOAPAction = v_sFollowOnRequestSOAPAction ? v_sFollowOnRequestSOAPAction : this.m_sFollowOnRequestSOAPAction;
  222. this.m_sCancelRequestSOAPAction = v_sCancelRequestSOAPAction ? v_sCancelRequestSOAPAction : this.m_sCancelRequestSOAPAction;
  223. };
  224. /**
  225. * @param {String} v_sPromptReport
  226. * @type void
  227. */
  228. C_mdsrvBusRequest.prototype.F_SetPromptReport = function( v_sPromptReport )
  229. {
  230. this.m_sPromptReport = v_sPromptReport;
  231. };
  232. /**
  233. * Creates an object context that can be used for a request.
  234. * @returns A context object that can be used for a request. The content object contains an m_eType attribute.
  235. * @type Object
  236. */
  237. C_mdsrvBusRequest.F_CreateContext = function(v_eType)
  238. {
  239. var v_oContext = {};
  240. v_oContext.m_eType = v_eType;
  241. return v_oContext;
  242. };
  243. /**
  244. * @type String
  245. */
  246. C_mdsrvBusRequest.K_sSOAPAction_metadataService_high = "http://developer.cognos.com/schemas/metadataService/3.high";
  247. /**
  248. * @type String
  249. */
  250. C_mdsrvBusRequest.K_sSOAPAction_metadataService_absolute = "http://developer.cognos.com/schemas/metadataService/3.absolute";
  251. /**
  252. * @type String
  253. */
  254. C_mdsrvBusRequest.K_sSOAPAction_metadataService_session = "http://developer.cognos.com/schemas/metadataService/3.session";
  255. /**
  256. * @type String
  257. */
  258. C_mdsrvBusRequest.K_sSOAPAction_metadataService_control = "http://developer.cognos.com/schemas/metadataService/3.session";
  259. /**
  260. * @type String
  261. */
  262. C_mdsrvBusRequest.K_sSOAPAction_contentManagerService = "http://developer.cognos.com/schemas/bibus/3#contentManagerService";
  263. //Based on FM Caspian RTC task 231966: MDSRV-SOAP ACTIONS - must amend for Planning bridging,
  264. //SOAP requests sent to Content Manager must look like this: http://www.ibm.com/xmlns/prod/cognos/contentManagerService/201109/.
  265. //So this C_mdsrvBusRequest.K_sSOAPAction_contentManagerService value has been out of date.
  266. //While global search shows it is used nowhere in mdsrv client. We should consider about remove this variable safely.
  267. /**
  268. * @type String
  269. */
  270. C_mdsrvBusRequest.K_sSOAPAction_systemService = "http://developer.cognos.com/schemas/bibus/3#systemService";
  271. C_mdsrvBusRequest.K_sSOAPAction_metadataService = "http://developer.cognos.com/schemas/bibus/3#metadataService";
  272. /**
  273. * @private
  274. */
  275. C_mdsrvBusRequest.k_sBIBusNamespace = "http://developer.cognos.com/schemas/bibus/3";
  276. /**
  277. * @private
  278. */
  279. C_mdsrvBusRequest.k_sBIBusNamespaceDecl = "xmlns:bus='" + C_mdsrvBusRequest.k_sBIBusNamespace + "/'";
  280. /**
  281. * @private
  282. */
  283. C_mdsrvBusRequest.k_sBIBusMDNamespaceDecl = "xmlns:md1='http://developer.cognos.com/schemas/metadataService/3'";
  284. /**
  285. * @param {String} v_sNamespace
  286. * @type void
  287. */
  288. C_mdsrvBusRequest.prototype.F_AddNamespace = function( v_sNamespace )
  289. {
  290. this.m_aNamespaces.push( v_sNamespace );
  291. };
  292. /**
  293. * @type void
  294. */
  295. C_mdsrvBusRequest.prototype.F_Send = function()
  296. {
  297. this.f_sendSoapRequest(
  298. this.f_createSoapRequest( this.m_sRequest, this.m_sProductLocale, this.m_sContentLocale ),
  299. this.m_sRequestSoapAction);
  300. };
  301. /**
  302. * @private
  303. */
  304. C_mdsrvBusRequest.prototype.f_sendSoapRequest = function(v_sSoapRequest, v_sSoapAction)
  305. {
  306. C_mdsrvBusRequest.m_sLastRequest = v_sSoapRequest;
  307. C_mdsrvBusRequest.m_sLastResponse = "";
  308. this.F_SetSoapAction(v_sSoapAction);
  309. this.F_SetRequestBody(v_sSoapRequest);
  310. C_mdsrvBusRequest.superClass.F_Send.call( this );
  311. };
  312. /**
  313. * @protected
  314. */
  315. C_mdsrvBusRequest.prototype.F_IsReadyToProcess = function()
  316. {
  317. if ( !C_mdsrvBusRequest.superClass.F_IsReadyToProcess.call( this ) )
  318. {
  319. return false;
  320. }
  321. delete this.m_oFollowOnState;
  322. // Check if any errors happened in the web request.
  323. if ( this.F_GetError() )
  324. {
  325. // allow the request to continue processing
  326. return !this.m_bPendingAbort;
  327. }
  328. var v_sResponseText = this.F_GetResponseText();
  329. var v_docResponse = U_XML.F_LoadString( null, v_sResponseText, false, true );
  330. this.m_docResponse = v_docResponse;
  331. if ( !v_docResponse || !v_docResponse.documentElement)
  332. {
  333. return !this.m_bPendingAbort;
  334. }
  335. this.m_docResponse.setProperty( "SelectionNamespaces", "xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " + this.m_aNamespaces.join( " " ) );
  336. C_mdsrvBusRequest.m_sLastResponse = v_docResponse.xml;
  337. var v_nFault = v_docResponse.selectSingleNode( '/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault' );
  338. if ( v_nFault && !this.m_bPendingAbort )
  339. {
  340. if (this.m_bServerPrompting && this.m_oListener && G_BusServer.F_AuthenticationRequired(v_docResponse))
  341. {
  342. this.m_bLoggingOn = true;
  343. //G_App.F_ShowXMLTree( v_docResponse, "Logon prompt response" );
  344. if (G_BusServer.F_Logon(this, v_docResponse))
  345. {
  346. // Depending on what happens after logon, either the request will be completed (failed)
  347. // or it will be re-executed
  348. delete this.m_docResponse;
  349. return false;
  350. }
  351. this.m_bLoggingOn = false;
  352. this.F_SetNewErrorRes( "IDS_CCHL_INITIATE_LOGON_FAILED" );
  353. }
  354. return true;
  355. }
  356. var v_nBusTracking = v_docResponse.selectSingleNode('/SOAP-ENV:Envelope/SOAP-ENV:Header/bus:biBusHeader/bus:tracking');
  357. if (v_nBusTracking)
  358. {
  359. var v_sBusTracking = v_nBusTracking.xml;
  360. if (this.m_bPendingAbort)
  361. {
  362. this.m_bPendingAbort = false;
  363. var v_bCancellable = (v_docResponse.selectSingleNode( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result[bus:status='working' or bus:status='stillWorking']" ) != null);
  364. this.m_oFollowOnState = this.f_createFollowOnState(v_docResponse, v_sBusTracking, v_bCancellable);
  365. this.F_Abort();
  366. return false;
  367. }
  368. // If there were no errors, then we can reuse the tracking
  369. // Make tracking available for resuse in subsequent requests.
  370. // If this request resubmits itself, then it should reuse the same tracking because it will be at the
  371. // top of the queue.
  372. C_mdsrvBusRequest.m_aBusTracking.push(v_sBusTracking);
  373. // An async method requires tracking to work correctly
  374. if (this.m_bAsyncBusRequest)
  375. {
  376. if (v_docResponse.selectSingleNode( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result[bus:status='complete'][bus:details/item/bus:status='responseReady']" ) )
  377. {
  378. delete this.m_docResponse;
  379. this.f_sendFollowOnRequest(this.m_sGetOutputMethod, v_docResponse, v_sBusTracking, false);
  380. return false;
  381. }
  382. else if (v_docResponse.selectSingleNode( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result[bus:status='working' or bus:status='stillWorking']" ) )
  383. {
  384. delete this.m_docResponse;
  385. this.f_sendFollowOnRequest(this.m_sWaitMethod, v_docResponse, v_sBusTracking, true);
  386. return false;
  387. }
  388. }
  389. }
  390. if (this.m_bPendingAbort)
  391. {
  392. // If the bus:tracking info is missing, then it is not possible to cancel this on the server
  393. this.f_forcePendingAbortOnClient();
  394. return false;
  395. }
  396. if (this.m_bServerPrompting && this.m_oListener && G_BusServer.F_RequiresServerPrompting(v_docResponse))
  397. {
  398. this.m_bIsPrompting = true;
  399. if (G_BusServer.F_DoPrompting(this, v_docResponse, this.m_sPromptReport))
  400. {
  401. // Depending on what happens after prompting, either the request will be completed (failed)
  402. // or it will be re-executed
  403. delete this.m_docResponse;
  404. return false;
  405. }
  406. this.m_bIsPrompting = false;
  407. this.F_SetNewErrorRes( "IDS_CCHL_INITIATE_SERVERPROMTING_FAILED" );
  408. return true;
  409. }
  410. return true;
  411. };
  412. /**
  413. * @protected
  414. */
  415. C_mdsrvBusRequest.prototype.F_ProcessResponse = function()
  416. {
  417. C_mdsrvBusRequest.superClass.F_ProcessResponse.call( this );
  418. if ( this.F_GetError() )
  419. {
  420. this.m_docResponse = null;
  421. return;
  422. }
  423. if (this.m_docResponse && this.m_docResponse.documentElement)
  424. {
  425. var v_nFault = this.m_docResponse.selectSingleNode( '/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault' );
  426. if ( v_nFault )
  427. {
  428. this.F_SetError( new C_BusSoapFault( this.m_docResponse ) );
  429. this.m_docResponse = null;
  430. }
  431. }
  432. else
  433. {
  434. var v_aMsg = [];
  435. var v_sResponseText = this.F_GetResponseText();
  436. if ( v_sResponseText )
  437. {
  438. v_aMsg.push( v_sResponseText );
  439. }
  440. else
  441. {
  442. v_aMsg.push(G_ResManager.F_GetString( "IDS_CCHL_HTTP_UNKNOWN_RESPONSE"));
  443. v_aMsg.push("\r\n");
  444. // These strings are hard coded, they are a last resort when there are problems.
  445. v_aMsg.push("Gateway URL: " + G_CCHL.M_sGatewayURL);
  446. v_aMsg.push("Document URL: " + document.URL);
  447. var v_sStatusText = this.F_GetStatusText();
  448. if ( v_sStatusText )
  449. {
  450. v_aMsg.push("HTTP Status Text: " + v_sStatusText);
  451. }
  452. }
  453. this.m_docResponse = null;
  454. this.F_SetNewErrorRes( "IDS_CCHL_XMLHTTPERROR", v_aMsg.join( "\r\n" ) );
  455. }
  456. };
  457. /**
  458. * @protected
  459. */
  460. C_mdsrvBusRequest.prototype.f_sendFollowOnRequest = function(v_sMethod, v_docResponse, v_sBusTracking, v_bCancellable)
  461. {
  462. G_Debug.F_Print("C_mdsrvBusRequest.f_sendFollowOnRequest : " + v_sMethod);
  463. this.m_oFollowOnState = this.f_createFollowOnState(v_docResponse, v_sBusTracking, v_bCancellable);
  464. var v_sRequest =
  465. "<" + v_sMethod + ">" +
  466. '<bus:conversation xsi:type="bus:asynchRequest">' +
  467. this.m_oFollowOnState.m_sConversation +
  468. '</bus:conversation>' +
  469. '<bus:parameterValues SOAP-ENC:arrayType="bus:parameterValue[]" xsi:type="SOAP-ENC:Array"/>' +
  470. '<bus:options SOAP-ENC:arrayType="bus:option[]" xsi:type="SOAP-ENC:Array"/>' +
  471. "</" + v_sMethod + ">";
  472. this.f_sendSoapRequest(this.f_createSoapRequest( v_sRequest, this.m_sProductLocale, this.m_sContentLocale ), this.m_sFollowOnRequestSOAPAction);
  473. };
  474. /**
  475. * Abort the current request.
  476. * @type void
  477. */
  478. C_mdsrvBusRequest.prototype.F_Abort = function()
  479. {
  480. if (this.m_bAsyncBusRequest && !this.m_oFollowOnState && !this.m_bCompleted)
  481. {
  482. G_Debug.F_Print("C_mdsrvBusRequest pending abort");
  483. /**
  484. * @private
  485. */
  486. this.m_bPendingAbort = true;
  487. // Force pending abort on the client after 10 seconds
  488. var v_oRequest = this;
  489. setTimeout(function() { v_oRequest.f_forcePendingAbortOnClient() }, 10000);
  490. if ( this.m_oListener && this.m_oListener.F_Request_OnAborted )
  491. {
  492. this.m_oListener.F_Request_OnAborted( this );
  493. }
  494. return;
  495. }
  496. C_mdsrvBusRequest.superClass.F_Abort.call( this );
  497. if (this.m_oFollowOnState && this.m_oFollowOnState.m_bCancellable)
  498. {
  499. this.f_cancelRequest();
  500. }
  501. };
  502. /**
  503. * @private
  504. * This method forces the client to abort the request. This is done to ensure that the browser client connections
  505. * do not get locked up waiting for a server response for cancel.
  506. */
  507. C_mdsrvBusRequest.prototype.f_forcePendingAbortOnClient = function()
  508. {
  509. if (this.m_bPendingAbort)
  510. {
  511. G_Debug.F_Print("C_mdsrvBusRequest pending abort forced on client");
  512. this.m_bCompleted = true; // ensures F_Abort does not fire the OnAbort event since it has already been fired.
  513. this.m_bPendingAbort = false;
  514. C_mdsrvBusRequest.superClass.F_Abort.call( this );
  515. }
  516. };
  517. /**
  518. * @private
  519. */
  520. C_mdsrvBusRequest.prototype.f_createFollowOnState = function(v_docResponse, v_sBusTracking, v_bCancellable)
  521. {
  522. var v_aConversation = [];
  523. var nl = v_docResponse.selectNodes( "/SOAP-ENV:Envelope/SOAP-ENV:Body/*/bus:result/bus:primaryRequest/*" );
  524. for ( var i = 0; i < nl.length; i++ )
  525. {
  526. v_aConversation.push(nl.item( i ).xml);
  527. }
  528. var v_sConversation = v_aConversation.join("");
  529. var v_oCancelState =
  530. {
  531. "m_sConversation" : v_sConversation,
  532. "m_sBusTracking" : v_sBusTracking,
  533. "m_bCancellable" : v_bCancellable
  534. };
  535. return v_oCancelState;
  536. };
  537. /**
  538. * @private
  539. */
  540. C_mdsrvBusRequest.prototype.f_cancelRequest = function()
  541. {
  542. G_Debug.F_Print("C_mdsrvBusRequest cancelling request on server");
  543. var v_sCancelConversation = this.m_oFollowOnState.m_sConversation;
  544. var v_sCancelBusTracking = this.m_oFollowOnState.m_sBusTracking;
  545. delete this.m_oFollowOnState;
  546. C_mdsrvBusRequest.m_aBusTracking.push(v_sCancelBusTracking);
  547. var v_sCancelRequest =
  548. "<" + this.m_sCancelMethod + ">" +
  549. '<bus:conversation xsi:type="bus:asynchRequest">' +
  550. v_sCancelConversation +
  551. '</bus:conversation>' +
  552. "</" + this.m_sCancelMethod + ">";
  553. var v_oCancelRequest = new C_mdsrvBusRequest( null, this.m_sCancelRequestSOAPAction, v_sCancelRequest );
  554. v_oCancelRequest.F_Send();
  555. };
  556. /**
  557. * @param {Boolean} v_bSuccess
  558. * @type void
  559. */
  560. C_mdsrvBusRequest.prototype.F_OnServerLogonComplete = function(v_bSuccess)
  561. {
  562. this.m_bIsLoggingOn = false;
  563. // if logon successful
  564. if (G_BusServer.F_GetPassport() && v_bSuccess )
  565. {
  566. this.F_Send();
  567. return;
  568. }
  569. this.F_SetNewErrorRes( "IDS_CCHL_REQUEST_CANCELLED_LOGON" );
  570. this.m_docResponse = null;
  571. this.m_oListener.F_Request_OnComplete(this);
  572. };
  573. /**
  574. * @type void
  575. */
  576. C_mdsrvBusRequest.prototype.F_OnServerPromptingComplete = function()
  577. {
  578. this.m_bIsPrompting = false;
  579. // if prompting was successful
  580. if (G_BusServer.F_HasParameterValues())
  581. {
  582. // take existing request and replace parameters with the new ones
  583. var v_sRequest = this.m_sRequest;
  584. var v_idxStartParams = v_sRequest.indexOf( "<bus:parameterValues" );
  585. var v_idxEndParams = v_sRequest.indexOf("</bus:parameterValues>" );
  586. if ( v_idxStartParams != - 1 && v_idxEndParams != -1 )
  587. {
  588. v_sRequest = v_sRequest.substring(0, v_idxStartParams) + G_BusServer.F_GetParameterValues() + v_sRequest.substring(v_idxEndParams + 22);
  589. }
  590. else if ( v_idxStartParams != - 1 && v_idxEndParams == -1 )
  591. {
  592. v_sParamsStart = v_sRequest.slice( v_idxStartParams );
  593. v_idxEndParams = v_sParamsStart.indexOf( "/>" );
  594. v_sRequest = v_sRequest.substring(0, v_idxStartParams) + G_BusServer.F_GetParameterValues() + v_sRequest.substring(v_idxStartParams + v_idxEndParams + 2);
  595. }
  596. else
  597. {
  598. G_Debug.F_Alert('Could not replace params in request');
  599. }
  600. this.m_sRequest = v_sRequest;
  601. this.F_Send();
  602. return;
  603. }
  604. this.F_SetNewErrorRes( "IDS_CCHL_REQUEST_CANCELLED_PROMPTING" );
  605. this.m_docResponse = null;
  606. this.m_oListener.F_Request_OnComplete(this);
  607. };
  608. /**
  609. * @private
  610. */
  611. C_mdsrvBusRequest.prototype.f_createSoapRequest = function( v_sRequest, v_sProductLocale, v_sContentLocale )
  612. {
  613. var v_sPassport = G_BusServer.F_GetPassport();
  614. var v_sRouterServerGroup = (this.m_sRoutingServerGroup === null) ? G_BusServer.F_GetRoutingServerGroup() : this.m_sRoutingServerGroup;
  615. var v_sCafContextId = G_BusServer.F_GetCafContextId();
  616. var v_sBusTracking = (C_mdsrvBusRequest.m_aBusTracking.length > 0) ? C_mdsrvBusRequest.m_aBusTracking.pop() : "";
  617. var v_sSOAPRequest =
  618. '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" ' + this.m_aNamespaces.join( " " ) + '>' +
  619. '<SOAP-ENV:Header>' +
  620. '<bus:biBusHeader xsi:type="bus:biBusHeader">' +
  621. (
  622. v_sPassport ?
  623. ('<bus:CAM xsi:type="bus:CAM">' +
  624. '<CAMPassport xsi:type="bus:CAMPassport">' +
  625. '<id xsi:type="xsd:string">' +
  626. v_sPassport +
  627. '</id>' +
  628. '</CAMPassport>' +
  629. '<authenticityToken xsi:type="xsd:base64Binary">' +
  630. G_BusServer.F_GetAuthenticityToken() +
  631. '</authenticityToken>' +
  632. '</bus:CAM>') : ''
  633. ) +
  634. (
  635. v_sCafContextId ?
  636. ('<bus:CAF xsi:type="bus:CAF">' +
  637. '<contextID xsi:type="xsd:string">' +
  638. v_sCafContextId +
  639. '</contextID>' +
  640. '</bus:CAF>') : ''
  641. ) +
  642. '<bus:userPreferenceVars SOAP-ENC:arrayType="bus:userPreferenceVar[]" xsi:type="SOAP-ENC:Array">' +
  643. '<item>' +
  644. '<bus:name xsi:type="xsd:string">productLocale</bus:name>' +
  645. '<bus:value xsi:type="xsd:string">' +
  646. (v_sProductLocale ? v_sProductLocale : G_CCHL.M_sProductLocale) +
  647. '</bus:value>' +
  648. '</item>' +
  649. '<item>' +
  650. '<bus:name xsi:type="xsd:string">contentLocale</bus:name>' +
  651. '<bus:value xsi:type="xsd:string">' +
  652. (v_sContentLocale ? v_sContentLocale : G_CCHL.M_sContentLocale) +
  653. '</bus:value>' +
  654. '</item>' +
  655. '</bus:userPreferenceVars>' +
  656. '<bus:dispatcherTransportVars xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:dispatcherTransportVar[]">' +
  657. '<item xsi:type="bus:dispatcherTransportVar">' +
  658. '<name xsi:type="xsd:string">md</name>' +
  659. '<value xsi:type="xsd:string">true</value>' +
  660. '</item>' +
  661. '</bus:dispatcherTransportVars>' +
  662. v_sBusTracking +
  663. (
  664. v_sRouterServerGroup ?
  665. ('<bus:routing xsi:type="bus:routingInfo">' +
  666. '<routingServerGroup xsi:type="xsd:string">' +
  667. v_sRouterServerGroup +
  668. '</routingServerGroup>' +
  669. '</bus:routing>') : ''
  670. ) +
  671. '</bus:biBusHeader>' +
  672. '</SOAP-ENV:Header>' +
  673. '<SOAP-ENV:Body>' +
  674. v_sRequest +
  675. '</SOAP-ENV:Body>' +
  676. '</SOAP-ENV:Envelope>';
  677. return v_sSOAPRequest;
  678. };
  679. /**
  680. * This class is used to capture the error contained in a BUS SOAP fault.
  681. *
  682. * @constructor
  683. * @extends I_Error
  684. * @param {XMLDocument} v_docSoapResponse
  685. */
  686. function C_BusSoapFault(v_docSoapResponse)
  687. {
  688. /**
  689. * @private
  690. */
  691. this.m_sErrorSummary = "";
  692. /**
  693. * @private
  694. */
  695. this.m_sErrorDetails = "";
  696. /**
  697. * @private
  698. */
  699. this.m_sErrorCode = "";
  700. v_docSoapResponse.setProperty( "SelectionNamespaces", "xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' " + C_mdsrvBusRequest.k_sBIBusNamespaceDecl );
  701. // Search the document since this class is also used for documents that are not
  702. // complete SOAP responses.
  703. var v_nFault = v_docSoapResponse.selectSingleNode('//SOAP-ENV:Fault');
  704. var nl = v_nFault.selectNodes(".//bus:messageString | .//messageString | .//bus:message[not(*)] | .//message[not(*)]");
  705. if (nl.length > 0)
  706. {
  707. var v_sMsg = nl.item(0).text;
  708. var i = v_sMsg.indexOf(" ");
  709. this.m_sErrorSummary = ( i > 0 ) ? v_sMsg.substring( i + 1 ) : v_sMsg;
  710. this.m_sErrorCode = ( i > 0 ) ? v_sMsg.substring( 0, i ) : "";
  711. var v_aDetails = [];
  712. for (var j = 1; j < nl.length; ++j)
  713. {
  714. v_aDetails.push(nl.item(j).text);
  715. }
  716. this.m_sErrorDetails = v_aDetails.join("\r\n");
  717. }
  718. else
  719. {
  720. var v_nFaultString = v_nFault.selectSingleNode("faultstring | SOAP-ENV:faultstring");
  721. if (v_nFaultString)
  722. {
  723. this.m_sErrorSummary = v_nFaultString.text;
  724. }
  725. var v_nFaultCode = v_nFault.selectSingleNode("faultcode | SOAP-ENV:faultcode");
  726. if (v_nFaultCode)
  727. {
  728. this.m_sErrorCode = v_nFaultCode.text;
  729. }
  730. }
  731. if (!this.m_sErrorSummary)
  732. {
  733. this.m_sErrorSummary = G_ResManager.F_GetString("IDS_CCHL_UNRECOGNIZED_SOAP_FAULT");
  734. this.m_sErrorDetails = v_nFault.xml;
  735. }
  736. };
  737. /**
  738. * @type String
  739. */
  740. C_BusSoapFault.prototype.F_GetErrorSummary = function()
  741. {
  742. return this.m_sErrorSummary;
  743. };
  744. /**
  745. * @type String
  746. */
  747. C_BusSoapFault.prototype.F_GetErrorDetails = function()
  748. {
  749. return this.m_sErrorDetails;
  750. };
  751. /**
  752. * @type String
  753. */
  754. C_BusSoapFault.prototype.F_GetErrorCode = function()
  755. {
  756. return this.m_sErrorCode;
  757. };