Skip to content

Commit c177b0e

Browse files
Support for SOAP client-side logging call-backs.
Co-authored-by: Jacob Sparre Andersen <JacobSparre.Andersen@consafelogistics.com>
1 parent 5268d30 commit c177b0e

File tree

5 files changed

+82
-15
lines changed

5 files changed

+82
-15
lines changed

src/soap/soap-client-callback.ads

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2018, AdaCore --
4+
-- Copyright (C) 2018-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -35,27 +35,23 @@ package SOAP.Client.Callback is
3535
-- Callback routine types
3636
type Pre_Call_CB is not null access
3737
procedure (Connection : AWS.Client.HTTP_Connection;
38-
SOAPAction : String;
3938
Request : SOAP.Message.Payload.Object;
4039
Schema : SOAP.WSDL.Schema.Definition);
4140

4241
type Post_Call_CB is not null access
4342
procedure (Connection : AWS.Client.HTTP_Connection;
44-
SOAPAction : String;
4543
Request : SOAP.Message.Payload.Object;
4644
Response : SOAP.Message.Response.Object'Class;
4745
Schema : SOAP.WSDL.Schema.Definition);
4846

4947
-- Default callback routines
5048
procedure Null_Pre_Call_Callback
5149
(Connection : AWS.Client.HTTP_Connection;
52-
SOAPAction : String;
5350
Request : SOAP.Message.Payload.Object;
5451
Schema : SOAP.WSDL.Schema.Definition) is null;
5552

5653
procedure Null_Post_Call_Callback
5754
(Connection : AWS.Client.HTTP_Connection;
58-
SOAPAction : String;
5955
Request : SOAP.Message.Payload.Object;
6056
Response : SOAP.Message.Response.Object'Class;
6157
Schema : SOAP.WSDL.Schema.Definition) is null;

tools/wsdl2aws-generator-stub.adb

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2003-2018, AdaCore --
4+
-- Copyright (C) 2003-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -501,8 +501,15 @@ package body Stub is
501501
" & SOAP.Message.XML.Image (Payload, Schema));");
502502
end if;
503503

504+
if O.Traces then
505+
Text_IO.Put_Line
506+
(Stub_Adb,
507+
" Pre_Call_Callback (Connection, Payload, Schema);");
508+
end if;
509+
504510
Text_IO.New_Line (Stub_Adb);
505511
Text_IO.Put_Line (Stub_Adb, " declare");
512+
506513
Text_IO.Put_Line
507514
(Stub_Adb,
508515
" Response : constant SOAP.Message.Response.Object'Class");
@@ -539,6 +546,13 @@ package body Stub is
539546
Text_IO.New_Line (Stub_Adb);
540547
end if;
541548

549+
if O.Traces then
550+
Text_IO.Put_Line
551+
(Stub_Adb,
552+
" Post_Call_Callback (Connection,"
553+
& " Payload, Response, Schema);");
554+
end if;
555+
542556
Text_IO.Put_Line
543557
(Stub_Adb,
544558
" if SOAP.Message.Response.Is_Error (Response) then");
@@ -803,6 +817,11 @@ package body Stub is
803817
end loop;
804818
end;
805819

820+
if O.Traces then
821+
Text_IO.Put
822+
(Stub_Adb, ", Pre_Call_Callback, Post_Call_Callback");
823+
end if;
824+
806825
Text_IO.Put_Line (Stub_Adb, ");");
807826

808827
if Output /= null then
@@ -845,6 +864,9 @@ package body Stub is
845864
Text_IO.New_Line (Stub_Ads);
846865
With_Unit (Stub_Ads, "Ada.Calendar", Elab => Off);
847866
Text_IO.New_Line (Stub_Ads);
867+
if O.Traces then
868+
With_Unit (Stub_Ads, "SOAP.Client.Callback", Elab => Off);
869+
end if;
848870
With_Unit (Stub_Ads, "SOAP.Types", Elab => Children);
849871
Text_IO.New_Line (Stub_Ads);
850872
With_Unit (Stub_Ads, U_Name & ".Types", Elab => Off);
@@ -857,6 +879,10 @@ package body Stub is
857879
Text_IO.New_Line (Stub_Ads);
858880
Text_IO.Put_Line (Stub_Ads, " use " & U_Name & ".Types;");
859881

882+
if O.Traces then
883+
Text_IO.Put_Line (Stub_Ads, " use SOAP.Client.Callback;");
884+
end if;
885+
860886
Text_IO.New_Line (Stub_Ads);
861887
Text_IO.Put_Line
862888
(Stub_Ads, " Connection : constant AWS.Client.HTTP_Connection;");
@@ -890,6 +916,7 @@ package body Stub is
890916
Text_IO.Put_Line (Stub_Adb, " use type SOAP.Parameters.List;");
891917
Text_IO.New_Line (Stub_Adb);
892918
Text_IO.Put_Line (Stub_Adb, " pragma Style_Checks (Off);");
919+
Text_IO.New_Line (Stub_Adb);
893920
end Start_Service;
894921

895922
end Stub;

tools/wsdl2aws-generator.adb

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,17 +1107,29 @@ package body WSDL2AWS.Generator is
11071107
Text_IO.Put_Line (File, " function " & L_Proc);
11081108
end if;
11091109

1110-
if Mode in Stub_Header then
1111-
Put_Indent ('(');
1112-
Text_IO.Put (File, "Connection : AWS.Client.HTTP_Connection");
1113-
end if;
1110+
Put_Indent ('(');
1111+
Text_IO.Put (File, "Connection : AWS.Client.HTTP_Connection");
11141112

11151113
if Input /= null then
11161114
Text_IO.Put_Line (File, ";");
11171115
Put_Indent;
11181116
Input_Parameters;
11191117
end if;
11201118

1119+
if O.Traces then
1120+
Text_IO.Put_Line (File, ";");
1121+
Put_Indent;
1122+
Text_IO.Put_Line
1123+
(File,
1124+
"Pre_Call_Callback : Pre_Call_CB "
1125+
& ":= Null_Pre_Call_Callback'Access;");
1126+
Put_Indent;
1127+
Text_IO.Put
1128+
(File,
1129+
"Post_Call_Callback : Post_Call_CB "
1130+
& ":= Null_Post_Call_Callback'Access");
1131+
end if;
1132+
11211133
if Input /= null or else Mode in Stub_Header then
11221134
Text_IO.Put (File, ")");
11231135
end if;
@@ -1158,7 +1170,22 @@ package body WSDL2AWS.Generator is
11581170
Text_IO.Put (File, (Max_Len - 8) * ' ');
11591171
Text_IO.Put
11601172
(File, " : AWS.Client.Timeouts_Values := "
1161-
& To_String (O.Unit) & ".Timeouts");
1173+
& To_String (O.Unit) & ".Timeouts");
1174+
1175+
if O.Traces then
1176+
Text_IO.Put_Line (File, ";");
1177+
Put_Indent;
1178+
Text_IO.Put_Line
1179+
(File,
1180+
"Pre_Call_Callback : Pre_Call_CB "
1181+
& ":= Null_Pre_Call_Callback'Access;");
1182+
Put_Indent;
1183+
Text_IO.Put
1184+
(File,
1185+
"Post_Call_Callback : Post_Call_CB "
1186+
& ":= Null_Post_Call_Callback'Access");
1187+
end if;
1188+
11621189
end if;
11631190

11641191
if Input /= null or else Mode in Stub_Header then
@@ -4494,6 +4521,15 @@ package body WSDL2AWS.Generator is
44944521
(Filename, Strings.Maps.To_Mapping ("-", "."));
44954522
end To_Unit_Name;
44964523

4524+
------------
4525+
-- Traces --
4526+
------------
4527+
4528+
procedure Traces (O : in out Object) is
4529+
begin
4530+
O.Traces := True;
4531+
end Traces;
4532+
44974533
----------------
44984534
-- Types_From --
44994535
----------------

tools/wsdl2aws-generator.ads

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2003-2018, AdaCore --
4+
-- Copyright (C) 2003-2020, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify --
77
-- it under terms of the GNU General Public License as published by the --
@@ -117,6 +117,9 @@ package WSDL2AWS.Generator is
117117
-- definition are already coded in Ada, it is preferable to reuse them to
118118
-- not have to convert to/from both definitions.
119119

120+
procedure Traces (O : in out Object);
121+
-- Generate traces callbacks from client stub code
122+
120123
procedure Types_From (O : in out Object; Spec : String);
121124
-- Use type definitions for Array and Record from this Ada spec instead of
122125
-- the one defined above. If there is no spec defined above, the procs are
@@ -173,6 +176,7 @@ private
173176
Stamp : Boolean := True;
174177
Unit : Unbounded_String;
175178
Spec : Unbounded_String;
179+
Traces : Boolean := False;
176180
Types_Spec : Unbounded_String;
177181
Main : Unbounded_String;
178182
Prefix : Unbounded_String;

tools/wsdl2aws-main.adb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Ada Web Server --
33
-- --
4-
-- Copyright (C) 2003-2017, AdaCore --
4+
-- Copyright (C) 2003-2020, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it --
77
-- under terms of the GNU General Public License as published by the --
@@ -145,7 +145,7 @@ procedure WSDL2AWS.Main is
145145
loop
146146
case Command_Line.Getopt
147147
("d q a e: f v s o: p: proxy: pu: pp: doc wsdl cvs nostub noskel "
148-
& "x: debug cb types: spec: main: n: timeouts:")
148+
& "x: debug cb traces types: spec: main: n: timeouts:")
149149
is
150150
when ASCII.NUL => exit;
151151

@@ -304,6 +304,9 @@ procedure WSDL2AWS.Main is
304304
end case;
305305
end;
306306

307+
elsif Command_Line.Full_Switch = "traces" then
308+
Generator.Traces (Gen);
309+
307310
else
308311
raise Syntax_Error;
309312
end if;
@@ -406,7 +409,8 @@ exception
406409
Put_Line (" -cvs Add CVS tag in unit's headers");
407410
Put_Line (" -nostub Do not create stub units");
408411
Put_Line (" -noskel Do not create skeleton units");
409-
Put_Line (" -cb Generate SOAP callback routine");
412+
Put_Line (" -cb Generate SOAP server callback routine");
413+
Put_Line (" -traces Generate SOAP client callbacks");
410414
Put_Line (" -x operation Exclude operation from code generation");
411415
Put_Line (" -spec spec Use procs/types from Ada spec");
412416
Put_Line (" -types spec Use types from Ada spec");

0 commit comments

Comments
 (0)