File: server.adb

package info (click to toggle)
polyorb 2.11~20140418-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,012 kB
  • ctags: 465
  • sloc: ada: 273,015; sh: 4,507; makefile: 4,265; python: 1,332; cpp: 1,213; java: 507; ansic: 274; xml: 30; perl: 23; exp: 6
file content (133 lines) | stat: -rw-r--r-- 5,442 bytes parent folder | download | duplicates (3)
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
------------------------------------------------------------------------------
--                                                                          --
--                           POLYORB COMPONENTS                             --
--                                                                          --
--                               S E R V E R                                --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--            Copyright (C) 2003 Free Software Foundation, Inc.             --
--                                                                          --
-- PolyORB is free software; you  can  redistribute  it and/or modify it    --
-- under terms of the  GNU General Public License as published by the  Free --
-- Software Foundation;  either version 2,  or (at your option)  any  later --
-- version. PolyORB is distributed  in the hope that it will be  useful,    --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License  for more details.  You should have received  a copy of the GNU  --
-- General Public License distributed with PolyORB; see file COPYING. If    --
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA.                                              --
--                                                                          --
--                                                                          --
--                PolyORB is maintained by ACT Europe.                      --
--                    (email: sales@act-europe.fr)                          --
--                                                                          --
------------------------------------------------------------------------------

with Ada.Text_IO; use Ada.Text_IO;

with AWS.Server;
with SOAP.Types;
with SOAP.Parameters;
with SOAP.Message;
with SOAP.Message.Payload;
with SOAP.Message.Response;
with AWS.Server.Servants;
with AWS.Status;
with AWS.Response;
with AWS.Parameters;

with PolyORB.Setup.No_Tasking_Server;
pragma Warnings (Off, PolyORB.Setup.No_Tasking_Server);

with PolyORB.References.IOR;
with PolyORB.References.URI;

procedure Server is

   function Callback
     (Request : in AWS.Status.Data)
      return AWS.Response.Data;

   function Callback
     (Request : in AWS.Status.Data)
      return AWS.Response.Data
   is
      use AWS.Status;
      use AWS.Response;

   begin
      if Is_SOAP (Request) then
         declare
            use SOAP.Types;
            use SOAP.Parameters;
            use SOAP.Message;
            use SOAP.Message.Payload;

            SOAP_Object : SOAP.Message.Payload.Object
              := AWS.Status.Payload (Request);
            P_List : SOAP.Parameters.List := Parameters (SOAP_Object);
            Mesg : constant String := SOAP.Parameters.Get (P_List, "Mesg");
            R  : SOAP.Message.Response.Object;
            RP : SOAP.Parameters.List;
         begin
            Put_Line ("Server: "
                      & Natural'Image (Argument_Count (P_List))
                      & " SOAP parameters");
            Put_Line ("Server: method is "
                      & Procedure_Name (SOAP_Object));
            Put_Line ("Server: echoing """ & Mesg & """");
            R := SOAP.Message.Response.From (SOAP_Object);
            RP := +S (Mesg, "result");
            SOAP.Message.Set_Parameters (R, RP);
            return AWS.Response.Build (R);
         end;
      else
         declare
            P_List : constant AWS.Parameters.List
              := AWS.Status.Parameters (D => Request);
            Mesg : constant String := AWS.Parameters.Get (P_List, "Mesg");
         begin
            Put_Line ("Server: the request is a web one");
            Put_Line ("Server: echoing """ & Mesg & """");
            return AWS.Response.Build ("text/html", Mesg);
         end;
      end if;

   end Callback;

begin
   Put_Line ("initializing PolyORB");
   AWS.Server.Initialization;
   Put_Line ("initialized");

   declare
      SOAP_Server : AWS.Server.Servants.SOAP_Servant;
      Web_Server : AWS.Server.Servants.Web_Servant;
   begin
      Put_Line ("starting servers");
      AWS.Server.Start (SOAP_Server, "soap_server",
                        Max_Connection => 1,
                        Callback       => Callback'Unrestricted_Access);
      AWS.Server.Start (Web_Server, "web_server",
                        Max_Connection => 1,
                        Callback       => Callback'Unrestricted_Access);
      Put_Line ("servers started");

      Put_Line ("SOAP_Server:");
      Put_Line (PolyORB.References.URI.Object_To_String
                (AWS.Server.Get_Server_Reference (SOAP_Server)));
      Put_Line ((PolyORB.References.IOR.Object_To_String
                 (AWS.Server.Get_Server_Reference (SOAP_Server))));

      Put_Line ("Web_Server:");
      Put_Line (PolyORB.References.URI.Object_To_String
                (AWS.Server.Get_Server_Reference (Web_Server)));
      Put_Line ((PolyORB.References.IOR.Object_To_String
                 (AWS.Server.Get_Server_Reference (Web_Server))));

      AWS.Server.Run;
   end;

end Server;