Added more content to the tutorial
This commit is contained in:
4
examples/tutorial/step_3/hello/ewf.ini
Normal file
4
examples/tutorial/step_3/hello/ewf.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
# For nino connector, use port 9999
|
||||
port=9999
|
||||
|
||||
#verbose=true
|
||||
20
examples/tutorial/step_3/hello/hello.ecf
Normal file
20
examples/tutorial/step_3/hello/hello.ecf
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="hello" uuid="088E8D53-3705-4362-B04D-8EDF0DBE50E5">
|
||||
|
||||
<target name="hello">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<root class="HELLO_APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="wsf" location="..\..\..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="default_nino" location="..\..\..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="src" location=".\src" recursive="true"/>
|
||||
</target>
|
||||
|
||||
</system>
|
||||
83
examples/tutorial/step_3/hello/src/hello_application.e
Normal file
83
examples/tutorial/step_3/hello/src/hello_application.e
Normal file
@@ -0,0 +1,83 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the `Hello World' service.
|
||||
|
||||
It inherits from WSF_DEFAULT_RESPONSE_SERVICE to get default EWF connector ready
|
||||
only `response' needs to be implemented.
|
||||
In this example, it is redefined and specialized to be WSF_PAGE_RESPONSE
|
||||
|
||||
`initialize' can be redefine to provide custom options if needed.
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
HELLO_APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_RESPONSE_SERVICE
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
response (req: WSF_REQUEST): WSF_HTML_PAGE_RESPONSE
|
||||
-- Computed response message.
|
||||
do
|
||||
--| It is now returning a WSF_HTML_PAGE_RESPONSE
|
||||
--| Since it is easier for building html page
|
||||
create Result.make
|
||||
Result.set_title ("EWF tutorial / Hello World!")
|
||||
--| Check if the request contains a parameter named "user"
|
||||
--| this could be a query, or a form parameter
|
||||
if attached req.string_item ("user") as f_user then
|
||||
--| If yes, say hello world #name
|
||||
Result.set_body ("Hello " + f_user.string + "!")
|
||||
--| We should html encode this name
|
||||
--| but to keep the example simple, we don't do that for now.
|
||||
else
|
||||
--| Otherwise, ask for name
|
||||
Result.set_body ("[
|
||||
<form action="/" method="POST">
|
||||
<p>Hello, what is your name?</p>
|
||||
<input type="text" name="user"/>
|
||||
<input type="submit" value="Validate"/>
|
||||
</form>
|
||||
]"
|
||||
)
|
||||
end
|
||||
|
||||
--| note:
|
||||
--| 1) Source of the parameter, we could have used
|
||||
--| req.query_parameter ("user") to search only in the query string
|
||||
--| req.form_parameter ("user") to search only in the form parameters
|
||||
--| 2) response type
|
||||
--| it could also have used WSF_PAGE_REPONSE, and build the html in the code
|
||||
--|
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
--| Uncomment the following line, to be able to load options from the file ewf.ini
|
||||
create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file ("ewf.ini")
|
||||
|
||||
--| You can also uncomment the following line if you use the Nino connector
|
||||
--| so that the server listens on port 9999
|
||||
--| quite often the port 80 is already busy
|
||||
-- set_service_option ("port", 9999)
|
||||
|
||||
--| Uncomment next line to have verbose option if available
|
||||
-- set_service_option ("verbose", True)
|
||||
|
||||
--| If you don't need any custom options, you are not obliged to redefine `initialize'
|
||||
Precursor
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user