# # FOURJS_START_COPYRIGHT(U,2011) # Property of Four Js* # (c) Copyright Four Js 2011, 2019. All Rights Reserved. # * Trademark of Four Js Development Tools Europe Ltd # in the United States and elsewhere # # Four Js and its suppliers do not warrant or guarantee that these samples # are accurate and suitable for your purposes. Their inclusion is purely for # information purposes only. # FOURJS_END_COPYRIGHT # IMPORT XML IMPORT COM GLOBALS "Types.4gl" DEFINE ret INTEGER DEFINE port STRING DEFINE now DATETIME HOUR TO FRACTION &define display_status(status) \ IF NOT screen THEN \ DISPLAY status \ ELSE \ DISPLAY status TO MSG \ MENU ON idle 1 EXIT MENU ON ACTION close EXIT PROGRAM END MENU \ END IF MAIN DEFER INTERRUPT LET screen = false # # Check arguments # IF num_args() = 2 and arg_val(1) = "-W" THEN LET serverURL = arg_val(2) CALL CreateShoppingCartService(true) EXIT PROGRAM ELSE IF num_args() = 2 and arg_val(1) = "-S" THEN LET screen = true CALL fgl_setenv("FGLAPPSERVER",arg_val(2)) CLOSE WINDOW SCREEN OPEN WINDOW w WITH FORM "Server" ATTRIBUTES(TEXT = "ShoppingCart service", STYLE="naked") display_status("ShoppingCart service startup") ELSE IF num_args() <> 0 THEN CALL exitHelp() EXIT PROGRAM END IF END IF END IF display_status("Initializing Shopping Cart service...") CALL InitGoods() CALL CreateShoppingCartService(false) display_status("... done") display_status("Starting Shopping Cart service") CALL com.WebServiceEngine.Start() display_status("... Shopping Cart service started") IF screen THEN MENU ON IDLE 1 LET now = CURRENT DISPLAY now||": Waiting..." TO MSG LET ret = com.WebServiceEngine.ProcessServices(1) CASE ret WHEN 0 DISPLAY "Request processed." TO msg WHEN -1 DISPLAY "No request..." TO msg WHEN -2 DISPLAY "Disconnected from application server." TO msg EXIT PROGRAM # The Application server has closed the connection WHEN -3 DISPLAY "Client Connection lost." TO msg WHEN -4 DISPLAY "Server interrupted with Ctrl-C." TO msg WHEN -9 DISPLAY "Unsupported operation." TO msg WHEN -10 DISPLAY "Internal server error." TO msg OTHERWISE DISPLAY "Unexpected server error " || status || "." TO msg EXIT MENU END CASE ON ACTION close EXIT PROGRAM END MENU ELSE WHILE TRUE LET now = CURRENT display_status(now||": Waiting...") LET ret = com.WebServiceEngine.ProcessServices(-1) CASE ret WHEN 0 display_status("... Request processed.") WHEN -2 DISPLAY "Disconnected from application server." EXIT PROGRAM # The Application server has closed the connection WHEN -3 DISPLAY "Client Connection lost." WHEN -4 DISPLAY "Server interrupted with Ctrl-C." WHEN -9 DISPLAY "Unsupported operation." WHEN -10 DISPLAY "Internal server error." OTHERWISE DISPLAY "Unexpected server error " || status || "." EXIT WHILE END CASE IF int_flag<>0 THEN LET int_flag=0 EXIT WHILE END IF END WHILE DISPLAY "Shopping Cart service stopped" END IF END MAIN FUNCTION exitHelp() DISPLAY "Usage: " DISPLAY " ", arg_val(0) DISPLAY " Start the server on port defined by FGLAPPSERVER" DISPLAY " ", arg_val(0), " -W serverurl" DISPLAY " Generate the WSDL file for the given url" DISPLAY " ", arg_val(0), " -S port" DISPLAY " Start service in graphical mode and on given port" EXIT PROGRAM END FUNCTION