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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895
|
------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2003-2018, AdaCore --
-- --
-- This library 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 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are --
-- granted additional permissions described in the GCC Runtime Library --
-- Exception, version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
------------------------------------------------------------------------------
with SOAP.Client;
separate (WSDL2AWS.Generator)
package body Stub is
-----------------
-- End_Service --
-----------------
procedure End_Service
(O : in out Object;
Name : String)
is
U_Name : constant String := To_Unit_Name (Format_Name (O, Name));
begin
-- Spec
Text_IO.New_Line (Stub_Ads);
Text_IO.Put_Line (Stub_Ads, "private");
Text_IO.New_Line (Stub_Ads);
Text_IO.Put_Line
(Stub_Ads, " Connection : constant AWS.Client.HTTP_Connection :=");
Text_IO.Put_Line
(Stub_Ads, " AWS.Client.Create");
Text_IO.Put_Line
(Stub_Ads, " (URL,");
Text_IO.Put
(Stub_Ads, " Timeouts => Timeouts");
-- Check if we need to generate proxy authentication
if O.Proxy = SOAP.Client.Not_Specified then
Text_IO.Put_Line (Stub_Ads, ");");
else
Text_IO.Put_Line (Stub_Ads, ",");
Text_IO.Put_Line
(Stub_Ads,
" Proxy => """
& To_String (O.Proxy) & """,");
Text_IO.Put_Line
(Stub_Ads,
" Proxy_User => """
& To_String (O.P_User) & """,");
Text_IO.Put_Line
(Stub_Ads,
" Proxy_Pwd => """
& To_String (O.P_Pwd) & """);");
end if;
Text_IO.New_Line (Stub_Ads);
Text_IO.Put_Line (Stub_Ads, "end " & U_Name & ".Client;");
-- Body
Text_IO.New_Line (Stub_Adb);
Text_IO.Put_Line (Stub_Adb, "end " & U_Name & ".Client;");
end End_Service;
-------------------
-- New_Procedure --
-------------------
procedure New_Procedure
(O : in out Object;
Proc : String;
Documentation : String;
SOAPAction : String;
Wrapper_Name : String;
Namespace : SOAP.Name_Space.Object;
Input : WSDL.Parameters.P_Set;
Output : WSDL.Parameters.P_Set;
Fault : WSDL.Parameters.P_Set)
is
use type SOAP.WSDL.Schema.Binding_Style;
use type WSDL.Parameters.P_Set;
use type WSDL.Types.Kind;
use all type SOAP.WSDL.Parameter_Type;
procedure Output_Parameter
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set);
-- Ouptut parameter
procedure Output_Simple
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set);
-- Output a simple parameter
procedure Output_Derived
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set);
-- Output a derived type parameter
procedure Output_Enumeration
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set);
-- Output an enumeration type parameter
procedure Output_Record
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set);
-- Output a record parameter
procedure Output_Array
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set);
-- Output an array parameter
procedure Output_Result (N : WSDL.Parameters.P_Set);
------------------
-- Output_Array --
------------------
procedure Output_Array
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set) is
begin
if Prefix = "" then
-- Not inside a record
Text_IO.Put
(Stub_Adb,
(if WSDL.Parameters.Is_Uniq (N.all)
then "SOAP_Array" else "SOAP_Set")
& "'(A (To_Object_Set ("
& Format_Name (O, To_String (N.Name))
& "), """ & To_String (N.Name) & """, """
& WSDL.Types.Name (N.Typ, True) & """))");
else
Text_IO.Put
(Stub_Adb,
(if WSDL.Parameters.Is_Uniq (N.all)
then "SOAP_Array" else "SOAP_Set")
& "'(A (To_Object_Set ("
& Prefix & Format_Name (O, To_String (N.Name))
& ".Item.all" & "), """ & To_String (N.Name) & """, """
& WSDL.Types.Name (N.Typ, True) & """))");
end if;
Output_Parameter (K + 1, Prefix, N.Next);
end Output_Array;
--------------------
-- Output_Derived --
--------------------
procedure Output_Derived
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set) is
begin
Text_IO.Put
(Stub_Adb,
WSDL.Parameters.To_SOAP
(P => N.all,
Object => Format_Name (O, To_String (N.Name)),
Name => Format_Name (O, To_String (N.Name)),
Type_Name => WSDL.Types.Name (N.Typ, NS => True)));
if Prefix /= "" and then N.Next /= null then
Text_IO.Put (Stub_Adb, ",");
end if;
Output_Parameter (K + 1, Prefix, N.Next);
end Output_Derived;
------------------------
-- Output_Enumeration --
------------------------
procedure Output_Enumeration
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set) is
begin
Text_IO.Put (Stub_Adb, "SOAP.Types.E");
Text_IO.Put
(Stub_Adb,
" (Types.Image ("
& Prefix & Format_Name (O, To_String (N.Name))
& "), """
& WSDL.Types.Name (N.Typ)
& """, """ & To_String (N.Name) & """)");
if Prefix /= "" and then N.Next /= null then
Text_IO.Put (Stub_Adb, ",");
end if;
Output_Parameter (K + 1, Prefix, N.Next);
end Output_Enumeration;
----------------------
-- Output_Parameter --
----------------------
procedure Output_Parameter
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set)
is
use Ada.Strings.Fixed;
begin
if N /= null then
if K = 1 then
Text_IO.Put (Stub_Adb, "+");
else
Text_IO.New_Line (Stub_Adb);
Text_IO.Put (Stub_Adb, ((K - 1) * 3) * ' ');
if Prefix = "" then
Text_IO.Put (Stub_Adb, " & ");
else
Text_IO.Put (Stub_Adb, " +");
end if;
end if;
case N.Mode is
when WSDL.Types.K_Simple =>
Output_Simple (K, Prefix, N);
when WSDL.Types.K_Derived =>
Output_Derived (K, Prefix, N);
when WSDL.Types.K_Enumeration =>
Output_Enumeration (K, Prefix, N);
when WSDL.Types.K_Array =>
Output_Array (K, Prefix, N);
when WSDL.Types.K_Record =>
Output_Record (K + 1, Prefix, N);
end case;
end if;
end Output_Parameter;
-------------------
-- Output_Record --
-------------------
procedure Output_Record
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set) is
begin
Text_IO.Put (Stub_Adb, "To_SOAP_Object (");
if Prefix = "" then
Text_IO.Put
(Stub_Adb,
Format_Name (O, To_String (N.Name))
& ", """ & To_String (N.Name) & """)");
else
Text_IO.Put
(Stub_Adb, Prefix & "." & Format_Name (O, To_String (N.Name))
& ", """ & To_String (N.Name) & """)");
end if;
Output_Parameter (K + 1, Prefix, N.Next);
end Output_Record;
-------------------
-- Output_Result --
-------------------
procedure Output_Result (N : WSDL.Parameters.P_Set) is
begin
if N.Mode = WSDL.Types.K_Array then
declare
Name : constant String :=
Format_Name (O, WSDL.Types.Name (N.Typ));
begin
Text_IO.Put_Line
(Stub_Adb,
"+To_" & Name & "_Type (V ");
Text_IO.Put_Line
(Stub_Adb,
" "
& "(SOAP.Types.SOAP_Array'(SOAP.Parameters.Get");
Text_IO.Put
(Stub_Adb,
" "
& "(R_Param, """ & To_String (N.Name) & """))))");
end;
else
if Is_String (N) then
-- First call operator to convert the string to an unbounded
-- string.
Text_IO.Put (Stub_Adb, "+");
end if;
if N.Mode = WSDL.Types.K_Derived then
Text_IO.Put
(Stub_Adb,
WSDL.Parameters.From_SOAP
(N.all,
Object => "SOAP.Parameters.Get (R_Param, """
& To_String (N.Name) & """)",
Is_SOAP_Type => True));
else
Text_IO.Put
(Stub_Adb,
"SOAP.Parameters.Get (R_Param, """
& To_String (N.Name) & """)");
end if;
end if;
end Output_Result;
-------------------
-- Output_Simple --
-------------------
procedure Output_Simple
(K : Positive;
Prefix : String;
N : WSDL.Parameters.P_Set)
is
P_Type : constant SOAP.WSDL.Parameter_Type :=
SOAP.WSDL.To_Type (WSDL.Types.Name (N.Typ));
NS : constant SOAP.Name_Space.Object :=
SOAP.WSDL.Name_Spaces.Get
(SOAP.Utils.NS (To_String (N.Elmt_Name)));
begin
if Prefix /= "" then
-- Inside a record
Text_IO.Put
(Stub_Adb,
SOAP.WSDL.Set_Routine (P_Type, Constrained => True));
else
Text_IO.Put (Stub_Adb, SOAP.WSDL.Set_Routine (P_Type));
end if;
Text_IO.Put
(Stub_Adb,
" (" & Prefix & Format_Name (O, To_String (N.Name))
& ", """ & To_String (N.Name) & ""","
& " Type_Name => """ & WSDL.Types.Name (N.Typ, True) & '"');
if SOAP.Name_Space.Is_Defined (NS) then
Text_IO.Put
(Stub_Adb,
", NS => SOAP.Name_Space.Create ("""
& SOAP.Name_Space.Name (NS)
& """, """ & SOAP.Name_Space.Value (NS) & """))");
else
Text_IO.Put (Stub_Adb, ")");
end if;
if Prefix /= "" and then N.Next /= null then
Text_IO.Put (Stub_Adb, ",");
end if;
Output_Parameter (K + 1, Prefix, N.Next);
end Output_Simple;
L_Proc : constant String := Format_Name (O, Proc);
W_Name : constant String := (if O.Style = SOAP.WSDL.Schema.Document
then Wrapper_Name else Proc);
use type SOAP.Name_Space.Object;
begin
-- Spec
Text_IO.New_Line (Stub_Ads);
Text_IO.Put (Stub_Ads, " ");
Put_Header (Stub_Ads, O, Proc, Input, Output, Mode => Stub_Spec);
Put_Header (Stub_Ads, O, Proc, Input, Output, Mode => C_Stub_Spec);
Output_Comment (Stub_Ads, Documentation, Indent => 3);
Text_IO.Put_Line
(Stub_Ads, " -- Raises SOAP.SOAP_Error if the procedure fails");
-- Body
Text_IO.New_Line (Stub_Adb);
Header_Box (O, Stub_Adb, Format_Name (O, Proc));
Text_IO.New_Line (Stub_Adb);
Put_Header (Stub_Adb, O, Proc, Input, Output, Mode => C_Stub_Body);
Text_IO.Put_Line
(Stub_Adb, " P_Set : SOAP.Parameters.List;");
Text_IO.Put_Line
(Stub_Adb, " Payload : SOAP.Message.Payload.Object;");
if Is_Simple_Wrapped_Parameter (O, Input) then
Text_IO.Put_Line
(Stub_Adb,
" " & Format_Name (O, To_String (Input.Name))
& " : "
& Format_Name (O, WSDL.Types.Name (Input.Typ) & "_Type")
& ';');
end if;
Text_IO.Put_Line (Stub_Adb, " begin");
Text_IO.Put_Line (Stub_Adb, " -- Set parameters");
-- Set parameters
if Is_Simple_Wrapped_Parameter (O, Input) then
-- Set individual fields of the input record
declare
N : WSDL.Parameters.P_Set := Input.P;
begin
while N /= null loop
Text_IO.Put
(Stub_Adb,
" " & Format_Name (O, To_String (Input.Name))
& "." & Format_Name (O, To_String (N.Name))
& " := ");
if Is_String (N)
or else N.Mode = WSDL.Types.K_Array
then
Text_IO.Put (Stub_Adb, '+');
end if;
Text_IO.Put_Line
(Stub_Adb, Format_Name (O, To_String (N.Name)) & ';');
N := N.Next;
end loop;
end;
end if;
if Input /= null then
Text_IO.Put (Stub_Adb, " P_Set := ");
Output_Parameter (1, "", Input);
Text_IO.Put_Line (Stub_Adb, ";");
end if;
Text_IO.Put_Line
(Stub_Adb, " Payload := SOAP.Message.Payload.Build");
Text_IO.Put
(Stub_Adb,
" (""" & To_String (O.Prefix) & W_Name & """, P_Set");
if Namespace = SOAP.Name_Space.No_Name_Space then
Text_IO.Put_Line (Stub_Adb, ");");
else
Text_IO.Put_Line (Stub_Adb, ",");
Text_IO.Put_Line
(Stub_Adb, " SOAP.Name_Space.Create ("""
& SOAP.Name_Space.Name (Namespace) & """, """
& SOAP.Name_Space.Value (Namespace) & """));");
end if;
if O.Debug then
Text_IO.New_Line (Stub_Adb);
Text_IO.Put_Line
(Stub_Adb,
" Put_Line (""[CLIENT/" & L_Proc & "] Payload : """);
Text_IO.Put_Line
(Stub_Adb,
" & SOAP.Message.XML.Image (Payload, Schema));");
end if;
Text_IO.New_Line (Stub_Adb);
Text_IO.Put_Line (Stub_Adb, " declare");
Text_IO.Put_Line
(Stub_Adb,
" Response : constant SOAP.Message.Response.Object'Class");
Text_IO.Put_Line
(Stub_Adb,
" := SOAP.Client.Call");
Text_IO.Put_Line
(Stub_Adb,
" (Connection, """
& To_String (O.Prefix) & SOAPAction & """,");
Text_IO.Put_Line
(Stub_Adb,
" Payload, Schema => Schema);");
Text_IO.Put_Line
(Stub_Adb,
" R_Param : constant SOAP.Parameters.List");
Text_IO.Put_Line
(Stub_Adb,
" := SOAP.Message.Parameters (Response);");
Text_IO.Put_Line (Stub_Adb, " begin");
if O.Debug then
Text_IO.Put_Line
(Stub_Adb,
" Put_Line (""[CLIENT/" & L_Proc & "] Response : """);
Text_IO.Put_Line
(Stub_Adb,
" "
& "& SOAP.Message.XML.Image (Response, Schema));");
Text_IO.New_Line (Stub_Adb);
end if;
Text_IO.Put_Line
(Stub_Adb,
" if SOAP.Message.Response.Is_Error (Response) then");
Text_IO.Put_Line
(Stub_Adb,
" raise SOAP.SOAP_Error with");
if WSDL.Parameters.Length (Fault) = 1 then
Text_IO.Put_Line
(Stub_Adb,
" SOAP.Parameters.Get (R_Param, "
& '"' & To_String (Fault.Name) & """);");
else
Text_IO.Put_Line
(Stub_Adb,
" SOAP.Parameters.Get (R_Param, "
& """faultstring"");");
end if;
if Output /= null then
Text_IO.Put_Line
(Stub_Adb,
" else");
Text_IO.Put_Line
(Stub_Adb,
" declare");
Text_IO.Put
(Stub_Adb,
" Result : constant ");
Text_IO.Put_Line (Stub_Adb, Result_Type (O, Proc, Output));
if WSDL.Parameters.Length (Output) = 1 then
-- A single parameter is returned
declare
T_Name : constant String := WSDL.Types.Name (Output.Typ);
begin
Text_IO.Put (Stub_Adb, " := ");
case Output.Mode is
when WSDL.Types.K_Simple =>
if SOAP.WSDL.To_Type (T_Name) = P_B64 then
Text_IO.Put_Line
(Stub_Adb,
"V (SOAP_Base64'(SOAP.Parameters.Get "
& "(R_Param, """
& To_String (Output.Name) & """)));");
elsif SOAP.WSDL.To_Type (T_Name) = P_Character then
Text_IO.Put
(Stub_Adb,
" SOAP.Utils.Get "
& "(SOAP.Parameters.Argument (R_Param, """);
Text_IO.Put (Stub_Adb, To_String (Output.Name));
Text_IO.Put_Line (Stub_Adb, """));");
else
Text_IO.Put_Line
(Stub_Adb,
"SOAP.Parameters.Get"
& " (R_Param, """
& To_String (Output.Name)
& """);");
end if;
when WSDL.Types.K_Derived =>
Text_IO.Put
(Stub_Adb,
WSDL.Parameters.From_SOAP
(Output.all,
Object => "SOAP.Parameters.Get (R_Param, """
& To_String (Output.Name) & '"',
Is_SOAP_Type => True));
Text_IO.Put_Line (Stub_Adb, ");");
when WSDL.Types.K_Enumeration =>
Text_IO.Put_Line
(Stub_Adb, Result_Type (O, Proc, Output));
Text_IO.Put_Line
(Stub_Adb,
" ("
& T_Name & "_Type'Value"
& " (SOAP.Utils.Get"
& " (SOAP.Parameters.Argument (R_Param, """
& To_String (Output.Name)
& """))));");
when WSDL.Types.K_Array =>
Text_IO.Put_Line
(Stub_Adb,
"To_" & Format_Name (O, T_Name) & "_Type");
Text_IO.Put_Line
(Stub_Adb,
" "
& "(V (SOAP_Array'(SOAP.Parameters.Get (R_Param, """
& To_String (Output.Name)
& """))));");
when WSDL.Types.K_Record =>
Text_IO.Put_Line
(Stub_Adb,
"To_" & Format_Name (O, T_Name) & "_Type");
Text_IO.Put_Line
(Stub_Adb,
" "
& "(SOAP_Record'(SOAP.Parameters.Get (R_Param, """
& To_String (Output.Name)
& """)));");
end case;
end;
else
Text_IO.Put
(Stub_Adb,
" := (");
declare
N : WSDL.Parameters.P_Set := Output;
begin
while N /= null loop
if N /= Output then
Text_IO.Put (Stub_Adb, ",");
Text_IO.New_Line (Stub_Adb);
Text_IO.Put (Stub_Adb, " ");
end if;
Output_Result (N);
N := N.Next;
end loop;
end;
Text_IO.Put_Line (Stub_Adb, ");");
end if;
Text_IO.Put_Line (Stub_Adb, " begin");
Text_IO.Put (Stub_Adb, " return ");
if Is_Simple_Wrapped_Parameter (O, Output)
and then WSDL.Parameters.Length (Output.P) = 1
and then Output.P.Mode /= WSDL.Types.K_Array
then
-- A simple field as result for a wrapped output, we want to
-- return the internal record field only as result.
declare
N : constant WSDL.Parameters.P_Set := Output.P;
begin
if Is_String (N) then
Text_IO.Put (Stub_Adb, '-');
end if;
Text_IO.Put (Stub_Adb, "Result.");
Text_IO.Put_Line (Stub_Adb, To_String (N.Name) & ';');
end;
else
Text_IO.Put_Line (Stub_Adb, "Result;");
end if;
Text_IO.Put_Line (Stub_Adb, " end;");
end if;
Text_IO.Put_Line (Stub_Adb, " end if;");
Text_IO.Put_Line (Stub_Adb, " end;");
Text_IO.Put_Line (Stub_Adb, " end " & L_Proc & ';');
-- Body stub based
Text_IO.New_Line (Stub_Adb);
Text_IO.Put (Stub_Adb, " ");
Put_Header (Stub_Adb, O, Proc, Input, Output, Mode => Stub_Body);
Text_IO.Put_Line
(Stub_Adb, " Connection : AWS.Client.HTTP_Connection;");
Text_IO.Put_Line
(Stub_Adb, " begin");
Text_IO.Put_Line
(Stub_Adb, " AWS.Client.Create");
Text_IO.Put_Line
(Stub_Adb, " (Connection, Endpoint,");
Text_IO.Put_Line
(Stub_Adb, " Persistent => False,");
Text_IO.Put
(Stub_Adb, " Timeouts => Timeouts");
-- Check if we need to generate proxy authentication
if O.Proxy = SOAP.Client.Not_Specified then
Text_IO.Put_Line (Stub_Adb, ");");
else
Text_IO.Put_Line (Stub_Adb, ",");
Text_IO.Put_Line
(Stub_Adb,
" Proxy => """
& To_String (O.Proxy) & """,");
Text_IO.Put_Line
(Stub_Adb,
" Proxy_User => """
& To_String (O.P_User) & """,");
Text_IO.Put_Line
(Stub_Adb,
" Proxy_Pwd => """
& To_String (O.P_Pwd) & """);");
end if;
if Output /= null then
Text_IO.Put_Line (Stub_Adb, " declare");
Text_IO.Put
(Stub_Adb, " Result : constant ");
if Is_Simple_Wrapped_Parameter (O, Output)
and then WSDL.Parameters.Length (Output.P) = 1
and then Output.P.Mode /= WSDL.Types.K_Array
then
-- A simple wrapped output with a single component, output proper
-- type in this case.
if Output.P.Mode = WSDL.Types.K_Simple then
Text_IO.Put
(Stub_Adb,
SOAP.WSDL.To_Ada
(SOAP.WSDL.To_Type (WSDL.Types.Name (Output.P.Typ))));
else
Text_IO.Put
(Stub_Adb,
Format_Name (O, WSDL.Types.Name (Output.P.Typ) & "_Type"));
end if;
else
Text_IO.Put (Stub_Adb, Result_Type (O, Proc, Output));
end if;
Text_IO.Put_Line (Stub_Adb, " :=");
Text_IO.Put (Stub_Adb, " ");
end if;
Text_IO.Put (Stub_Adb, " Client." & L_Proc & " (Connection");
declare
N : WSDL.Parameters.P_Set;
begin
if Is_Simple_Wrapped_Parameter (O, Input) then
N := Input.P;
else
N := Input;
end if;
while N /= null loop
declare
Name : constant String := Format_Name (O, To_String (N.Name));
begin
Text_IO.Put (Stub_Adb, ", " & Name);
end;
N := N.Next;
end loop;
end;
Text_IO.Put_Line (Stub_Adb, ");");
if Output /= null then
Text_IO.Put_Line (Stub_Adb, " begin");
Text_IO.Put (Stub_Adb, " ");
end if;
Text_IO.Put_Line (Stub_Adb, " AWS.Client.Close (Connection);");
if Output /= null then
Text_IO.Put_Line (Stub_Adb, " return Result;");
Text_IO.Put_Line (Stub_Adb, " end;");
end if;
Text_IO.Put_Line (Stub_Adb, " exception");
Text_IO.Put_Line (Stub_Adb, " when others =>");
Text_IO.Put_Line (Stub_Adb, " AWS.Client.Close (Connection);");
Text_IO.Put_Line (Stub_Adb, " raise;");
Text_IO.Put_Line (Stub_Adb, " end " & L_Proc & ';');
end New_Procedure;
-------------------
-- Start_Service --
-------------------
procedure Start_Service
(O : in out Object;
Name : String;
Root_Documentation : String;
Documentation : String;
Location : String)
is
pragma Unreferenced (Root_Documentation, Location);
U_Name : constant String := To_Unit_Name (Format_Name (O, Name));
begin
-- Spec
Text_IO.Put_Line (Stub_Ads, "pragma Warnings (Off);");
Text_IO.New_Line (Stub_Ads);
With_Unit (Stub_Ads, "Ada.Calendar", Elab => Off);
Text_IO.New_Line (Stub_Ads);
With_Unit (Stub_Ads, "SOAP.Types", Elab => Children);
Text_IO.New_Line (Stub_Ads);
With_Unit (Stub_Ads, U_Name & ".Types", Elab => Off);
Text_IO.New_Line (Stub_Ads);
Output_Comment (Stub_Ads, Documentation, Indent => 0);
Text_IO.New_Line (Stub_Ads);
Text_IO.Put_Line (Stub_Ads, "package " & U_Name & ".Client is");
Text_IO.New_Line (Stub_Ads);
Text_IO.Put_Line (Stub_Ads, " use " & U_Name & ".Types;");
Text_IO.New_Line (Stub_Ads);
Text_IO.Put_Line
(Stub_Ads, " Connection : constant AWS.Client.HTTP_Connection;");
-- Body
Text_IO.Put_Line (Stub_Adb, "pragma Warnings (Off);");
Text_IO.New_Line (Stub_Adb);
if O.Debug then
With_Unit (Stub_Adb, "Ada.Text_IO", Elab => Off);
With_Unit (Stub_Adb, "SOAP.Message.XML");
end if;
With_Unit (Stub_Adb, "SOAP.Client");
With_Unit (Stub_Adb, "SOAP.Message.Payload", Elab => Children);
With_Unit (Stub_Adb, "SOAP.Message.Response");
With_Unit (Stub_Adb, "SOAP.Message.XML");
With_Unit (Stub_Adb, "SOAP.Name_Space");
With_Unit (Stub_Adb, "SOAP.Parameters");
With_Unit (Stub_Adb, "SOAP.Utils");
Text_IO.New_Line (Stub_Adb);
Text_IO.Put_Line (Stub_Adb, "package body " & U_Name & ".Client is");
Text_IO.New_Line (Stub_Adb);
if O.Debug then
Text_IO.Put_Line (Stub_Adb, " use Ada.Text_IO;");
end if;
Text_IO.Put_Line (Stub_Adb, " use SOAP.Types;");
Text_IO.Put_Line (Stub_Adb, " use type SOAP.Parameters.List;");
Text_IO.New_Line (Stub_Adb);
Text_IO.Put_Line (Stub_Adb, " pragma Style_Checks (Off);");
end Start_Service;
end Stub;
|