From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- samples/AUTHORS | 26 + samples/COPYING | 203 ++++++++ samples/ChangeLog | 215 ++++++++ samples/INSTALL | 14 + samples/LICENSE | 203 ++++++++ samples/Makefile.am | 8 + samples/NEWS | 97 ++++ samples/README | 51 ++ samples/autogen.sh | 51 ++ samples/build.sh | 8 + samples/client/Makefile.am | 2 + samples/client/amqp/Makefile.am | 1 + samples/client/amqp/echo/Makefile.am | 36 ++ samples/client/amqp/echo/echo_blocking.c | 124 +++++ samples/client/amqp/echo/echo_blocking_addr.c | 132 +++++ samples/client/amqp/echo/echo_blocking_dual.c | 142 ++++++ samples/client/amqp/echo/echo_blocking_soap11.c | 135 +++++ samples/client/amqp/echo/echo_non_blocking.c | 217 ++++++++ samples/client/amqp/echo/echo_non_blocking_dual.c | 235 +++++++++ samples/client/amqp/echo/echo_util.c | 47 ++ samples/client/amqp/echo/echo_util.h | 54 ++ samples/client/amqp/mtom/Makefile.am | 18 + samples/client/amqp/mtom/mtom_client.c | 259 ++++++++++ samples/client/amqp/mtom/resources/Makefile.am | 5 + samples/client/amqp/mtom/resources/axis2.jpg | Bin 0 -> 13887 bytes samples/client/amqp/notify/Makefile.am | 15 + samples/client/amqp/notify/notify_client.c | 152 ++++++ samples/client/echo/Makefile.am | 18 + samples/client/echo/README.txt | 5 + samples/client/echo/echo.c | 196 ++++++++ samples/client/echo/echo.mk | 8 + samples/client/google/Makefile.am | 17 + samples/client/google/README.txt | 10 + samples/client/google/google.mk | 8 + samples/client/google/google_client.c | 290 +++++++++++ samples/client/math/Makefile.am | 20 + samples/client/math/axis2_math_stub.c | 193 +++++++ samples/client/math/axis2_math_stub.h | 86 ++++ samples/client/math/math.mk | 8 + samples/client/math/math_client.c | 201 ++++++++ samples/client/math/services.xml | 18 + samples/client/mtom/Makefile.am | 20 + samples/client/mtom/mtom.mk | 8 + samples/client/mtom/mtom_client.c | 271 ++++++++++ samples/client/mtom/resources/Makefile.am | 3 + samples/client/mtom/resources/axis2.jpg | Bin 0 -> 13887 bytes samples/client/mtom_callback/Makefile.am | 19 + samples/client/mtom_callback/mtom_callback.mk | 4 + .../client/mtom_callback/mtom_callback_client.c | 261 ++++++++++ samples/client/notify/Makefile.am | 18 + samples/client/notify/notify.mk | 8 + samples/client/notify/notify_client.c | 152 ++++++ samples/client/version/Makefile.am | 19 + samples/client/version/axis2_version_stub.c | 114 +++++ samples/client/version/axis2_version_stub.h | 71 +++ samples/client/version/services.xml | 9 + samples/client/version/test.xml | 5 + samples/client/version/version_client.c | 185 +++++++ samples/client/yahoo/Makefile.am | 17 + samples/client/yahoo/yahoo.mk | 8 + samples/client/yahoo/yahoo_client.c | 207 ++++++++ samples/codegen/client/calc_xml_inout/Makefile.am | 24 + samples/codegen/client/calc_xml_inout/readme | 12 + .../client/calc_xml_inout/test_calculator.c | 125 +++++ samples/codegen/client/calculator/Makefile.am | 26 + samples/codegen/client/calculator/readme | 15 + .../codegen/client/calculator/test_calculator.c | 77 +++ samples/codegen/client/interop_doc1/Makefile.am | 56 +++ samples/codegen/client/interop_doc1/readme | 13 + .../codegen/client/interop_doc1/test_echo_date.c | 77 +++ .../client/interop_doc1/test_echo_struct_array.c | 93 ++++ samples/codegen/client/interop_doc2/Makefile.am | 42 ++ samples/codegen/client/interop_doc2/readme | 13 + .../codegen/client/interop_doc2/test_echo_string.c | 70 +++ .../client/interop_doc2/test_echo_string_array.c | 90 ++++ .../codegen/client/interop_doc2/test_echo_struct.c | 89 ++++ .../codegen/databinding/Calculator/Calculator.wsdl | 255 ++++++++++ .../databinding/Calculator/client/CalculatorAdd.c | 38 ++ .../Calculator/server/axis2_skel_Calculator.c | 104 ++++ samples/codegen/databinding/READEME.txt | 66 +++ .../databinding/StockQuoteService/StockQuote.xsd | 46 ++ .../StockQuoteService/StockQuoteService.wsdl | 44 ++ .../StockQuoteService/client/stock_quote_client.c | 121 +++++ .../server/axis2_skel_StockQuoteService.c | 75 +++ samples/codegen/server/calc_xml_inout/Makefile.am | 14 + .../server/calc_xml_inout/axis2_skel_Calculator.c | 135 +++++ samples/codegen/server/calc_xml_inout/readme | 12 + samples/codegen/server/calculator/Makefile.am | 15 + .../server/calculator/axis2_skel_Calculator.c | 158 ++++++ samples/codegen/server/calculator/readme | 12 + samples/codegen/server/interop_doc1/Makefile.am | 23 + .../axis2_skel_InteropTestPortTypeDocService.c | 274 ++++++++++ samples/codegen/server/interop_doc1/readme | 10 + samples/codegen/server/interop_doc2/Makefile.am | 16 + .../axis2_skel_WSDLInteropTestDocLitService.c | 139 ++++++ samples/codegen/server/interop_doc2/readme | 10 + samples/configure.ac | 154 ++++++ samples/mtom_caching_callback/Makefile.am | 10 + .../mtom_caching_callback/mtom_caching_callback.c | 184 +++++++ samples/mtom_sending_callback/Makefile.am | 11 + .../mtom_sending_callback/mtom_sending_callback.c | 209 ++++++++ samples/server/Calculator/Calculator.mk | 7 + samples/server/Calculator/Calculator.wsdl | 183 +++++++ samples/server/Calculator/Makefile.am | 9 + samples/server/Calculator/calc.c | 553 +++++++++++++++++++++ samples/server/Calculator/calc.h | 41 ++ samples/server/Calculator/calc_skeleton.c | 157 ++++++ samples/server/Calculator/services.xml | 28 ++ samples/server/Makefile.am | 2 + samples/server/axis2.log | 1 + samples/server/axis2.xml | 129 +++++ samples/server/echo/Makefile.am | 9 + samples/server/echo/echo.c | 116 +++++ samples/server/echo/echo.h | 32 ++ samples/server/echo/echo.mk | 8 + samples/server/echo/echo_skeleton.c | 182 +++++++ samples/server/echo/services.xml | 34 ++ samples/server/math/Makefile.am | 9 + samples/server/math/math.c | 537 ++++++++++++++++++++ samples/server/math/math.h | 41 ++ samples/server/math/math.mk | 7 + samples/server/math/math_skeleton.c | 157 ++++++ samples/server/math/services.xml | 18 + samples/server/mtom/Makefile.am | 9 + samples/server/mtom/mtom.c | 261 ++++++++++ samples/server/mtom/mtom.h | 33 ++ samples/server/mtom/mtom.mk | 8 + samples/server/mtom/mtom_skeleton.c | 166 +++++++ samples/server/mtom/services.xml | 12 + samples/server/mtom_callback/Makefile.am | 9 + samples/server/mtom_callback/mtom_callback.c | 261 ++++++++++ samples/server/mtom_callback/mtom_callback.h | 33 ++ samples/server/mtom_callback/mtom_callback.mk | 8 + samples/server/mtom_callback/mtom_skeleton.c | 166 +++++++ samples/server/mtom_callback/services.xml | 16 + samples/server/notify/Makefile.am | 9 + samples/server/notify/notify.c | 77 +++ samples/server/notify/notify.h | 32 ++ samples/server/notify/notify.mk | 8 + samples/server/notify/notify_skeleton.c | 167 +++++++ samples/server/notify/services.xml | 13 + samples/server/sg_math/Makefile.am | 11 + samples/server/sg_math/add.c | 180 +++++++ samples/server/sg_math/add.h | 33 ++ samples/server/sg_math/add_skeleton.c | 151 ++++++ samples/server/sg_math/div.c | 150 ++++++ samples/server/sg_math/div.h | 32 ++ samples/server/sg_math/div_skeleton.c | 151 ++++++ samples/server/sg_math/mul.c | 148 ++++++ samples/server/sg_math/mul.h | 32 ++ samples/server/sg_math/mul_skeleton.c | 151 ++++++ samples/server/sg_math/services.xml | 30 ++ samples/server/sg_math/sg_math.mk | 15 + samples/server/sg_math/sub.c | 148 ++++++ samples/server/sg_math/sub.h | 32 ++ samples/server/sg_math/sub_skeleton.c | 151 ++++++ samples/server/version/Makefile.am | 10 + samples/server/version/services.xml | 9 + samples/server/version/version.c | 59 +++ samples/server/version/version.h | 32 ++ samples/server/version/version_skel.c | 151 ++++++ samples/user_guide/Makefile.am | 1 + samples/user_guide/clients/Makefile.am | 37 ++ samples/user_guide/clients/echo_blocking.c | 126 +++++ samples/user_guide/clients/echo_blocking.mk | 8 + samples/user_guide/clients/echo_blocking_addr.c | 132 +++++ samples/user_guide/clients/echo_blocking_addr.mk | 8 + samples/user_guide/clients/echo_blocking_auth.c | 295 +++++++++++ samples/user_guide/clients/echo_blocking_auth.mk | 8 + samples/user_guide/clients/echo_blocking_dual.c | 140 ++++++ samples/user_guide/clients/echo_blocking_dual.mk | 8 + samples/user_guide/clients/echo_blocking_soap11.c | 135 +++++ samples/user_guide/clients/echo_blocking_soap11.mk | 8 + samples/user_guide/clients/echo_non_blocking.c | 211 ++++++++ samples/user_guide/clients/echo_non_blocking.mk | 8 + .../user_guide/clients/echo_non_blocking_dual.c | 233 +++++++++ .../user_guide/clients/echo_non_blocking_dual.mk | 8 + samples/user_guide/clients/echo_rest.c | 229 +++++++++ samples/user_guide/clients/echo_rest.mk | 8 + samples/user_guide/clients/echo_util.c | 48 ++ samples/user_guide/clients/echo_util.h | 28 ++ 181 files changed, 14787 insertions(+) create mode 100644 samples/AUTHORS create mode 100644 samples/COPYING create mode 100644 samples/ChangeLog create mode 100644 samples/INSTALL create mode 100644 samples/LICENSE create mode 100644 samples/Makefile.am create mode 100644 samples/NEWS create mode 100644 samples/README create mode 100755 samples/autogen.sh create mode 100755 samples/build.sh create mode 100644 samples/client/Makefile.am create mode 100644 samples/client/amqp/Makefile.am create mode 100644 samples/client/amqp/echo/Makefile.am create mode 100644 samples/client/amqp/echo/echo_blocking.c create mode 100644 samples/client/amqp/echo/echo_blocking_addr.c create mode 100644 samples/client/amqp/echo/echo_blocking_dual.c create mode 100644 samples/client/amqp/echo/echo_blocking_soap11.c create mode 100644 samples/client/amqp/echo/echo_non_blocking.c create mode 100644 samples/client/amqp/echo/echo_non_blocking_dual.c create mode 100644 samples/client/amqp/echo/echo_util.c create mode 100644 samples/client/amqp/echo/echo_util.h create mode 100644 samples/client/amqp/mtom/Makefile.am create mode 100644 samples/client/amqp/mtom/mtom_client.c create mode 100644 samples/client/amqp/mtom/resources/Makefile.am create mode 100644 samples/client/amqp/mtom/resources/axis2.jpg create mode 100644 samples/client/amqp/notify/Makefile.am create mode 100644 samples/client/amqp/notify/notify_client.c create mode 100644 samples/client/echo/Makefile.am create mode 100644 samples/client/echo/README.txt create mode 100644 samples/client/echo/echo.c create mode 100644 samples/client/echo/echo.mk create mode 100644 samples/client/google/Makefile.am create mode 100644 samples/client/google/README.txt create mode 100644 samples/client/google/google.mk create mode 100644 samples/client/google/google_client.c create mode 100644 samples/client/math/Makefile.am create mode 100644 samples/client/math/axis2_math_stub.c create mode 100644 samples/client/math/axis2_math_stub.h create mode 100644 samples/client/math/math.mk create mode 100644 samples/client/math/math_client.c create mode 100644 samples/client/math/services.xml create mode 100644 samples/client/mtom/Makefile.am create mode 100644 samples/client/mtom/mtom.mk create mode 100644 samples/client/mtom/mtom_client.c create mode 100644 samples/client/mtom/resources/Makefile.am create mode 100644 samples/client/mtom/resources/axis2.jpg create mode 100644 samples/client/mtom_callback/Makefile.am create mode 100644 samples/client/mtom_callback/mtom_callback.mk create mode 100644 samples/client/mtom_callback/mtom_callback_client.c create mode 100644 samples/client/notify/Makefile.am create mode 100644 samples/client/notify/notify.mk create mode 100644 samples/client/notify/notify_client.c create mode 100644 samples/client/version/Makefile.am create mode 100644 samples/client/version/axis2_version_stub.c create mode 100644 samples/client/version/axis2_version_stub.h create mode 100644 samples/client/version/services.xml create mode 100644 samples/client/version/test.xml create mode 100644 samples/client/version/version_client.c create mode 100644 samples/client/yahoo/Makefile.am create mode 100644 samples/client/yahoo/yahoo.mk create mode 100644 samples/client/yahoo/yahoo_client.c create mode 100644 samples/codegen/client/calc_xml_inout/Makefile.am create mode 100644 samples/codegen/client/calc_xml_inout/readme create mode 100644 samples/codegen/client/calc_xml_inout/test_calculator.c create mode 100644 samples/codegen/client/calculator/Makefile.am create mode 100644 samples/codegen/client/calculator/readme create mode 100644 samples/codegen/client/calculator/test_calculator.c create mode 100644 samples/codegen/client/interop_doc1/Makefile.am create mode 100644 samples/codegen/client/interop_doc1/readme create mode 100644 samples/codegen/client/interop_doc1/test_echo_date.c create mode 100644 samples/codegen/client/interop_doc1/test_echo_struct_array.c create mode 100644 samples/codegen/client/interop_doc2/Makefile.am create mode 100644 samples/codegen/client/interop_doc2/readme create mode 100644 samples/codegen/client/interop_doc2/test_echo_string.c create mode 100644 samples/codegen/client/interop_doc2/test_echo_string_array.c create mode 100644 samples/codegen/client/interop_doc2/test_echo_struct.c create mode 100644 samples/codegen/databinding/Calculator/Calculator.wsdl create mode 100644 samples/codegen/databinding/Calculator/client/CalculatorAdd.c create mode 100644 samples/codegen/databinding/Calculator/server/axis2_skel_Calculator.c create mode 100644 samples/codegen/databinding/READEME.txt create mode 100644 samples/codegen/databinding/StockQuoteService/StockQuote.xsd create mode 100644 samples/codegen/databinding/StockQuoteService/StockQuoteService.wsdl create mode 100644 samples/codegen/databinding/StockQuoteService/client/stock_quote_client.c create mode 100644 samples/codegen/databinding/StockQuoteService/server/axis2_skel_StockQuoteService.c create mode 100644 samples/codegen/server/calc_xml_inout/Makefile.am create mode 100644 samples/codegen/server/calc_xml_inout/axis2_skel_Calculator.c create mode 100644 samples/codegen/server/calc_xml_inout/readme create mode 100644 samples/codegen/server/calculator/Makefile.am create mode 100644 samples/codegen/server/calculator/axis2_skel_Calculator.c create mode 100644 samples/codegen/server/calculator/readme create mode 100644 samples/codegen/server/interop_doc1/Makefile.am create mode 100644 samples/codegen/server/interop_doc1/axis2_skel_InteropTestPortTypeDocService.c create mode 100644 samples/codegen/server/interop_doc1/readme create mode 100644 samples/codegen/server/interop_doc2/Makefile.am create mode 100644 samples/codegen/server/interop_doc2/axis2_skel_WSDLInteropTestDocLitService.c create mode 100644 samples/codegen/server/interop_doc2/readme create mode 100644 samples/configure.ac create mode 100644 samples/mtom_caching_callback/Makefile.am create mode 100644 samples/mtom_caching_callback/mtom_caching_callback.c create mode 100644 samples/mtom_sending_callback/Makefile.am create mode 100644 samples/mtom_sending_callback/mtom_sending_callback.c create mode 100644 samples/server/Calculator/Calculator.mk create mode 100644 samples/server/Calculator/Calculator.wsdl create mode 100644 samples/server/Calculator/Makefile.am create mode 100644 samples/server/Calculator/calc.c create mode 100644 samples/server/Calculator/calc.h create mode 100644 samples/server/Calculator/calc_skeleton.c create mode 100644 samples/server/Calculator/services.xml create mode 100644 samples/server/Makefile.am create mode 100644 samples/server/axis2.log create mode 100644 samples/server/axis2.xml create mode 100644 samples/server/echo/Makefile.am create mode 100644 samples/server/echo/echo.c create mode 100644 samples/server/echo/echo.h create mode 100644 samples/server/echo/echo.mk create mode 100644 samples/server/echo/echo_skeleton.c create mode 100644 samples/server/echo/services.xml create mode 100644 samples/server/math/Makefile.am create mode 100644 samples/server/math/math.c create mode 100644 samples/server/math/math.h create mode 100644 samples/server/math/math.mk create mode 100644 samples/server/math/math_skeleton.c create mode 100644 samples/server/math/services.xml create mode 100644 samples/server/mtom/Makefile.am create mode 100644 samples/server/mtom/mtom.c create mode 100644 samples/server/mtom/mtom.h create mode 100644 samples/server/mtom/mtom.mk create mode 100644 samples/server/mtom/mtom_skeleton.c create mode 100644 samples/server/mtom/services.xml create mode 100644 samples/server/mtom_callback/Makefile.am create mode 100644 samples/server/mtom_callback/mtom_callback.c create mode 100644 samples/server/mtom_callback/mtom_callback.h create mode 100644 samples/server/mtom_callback/mtom_callback.mk create mode 100644 samples/server/mtom_callback/mtom_skeleton.c create mode 100644 samples/server/mtom_callback/services.xml create mode 100644 samples/server/notify/Makefile.am create mode 100644 samples/server/notify/notify.c create mode 100644 samples/server/notify/notify.h create mode 100644 samples/server/notify/notify.mk create mode 100644 samples/server/notify/notify_skeleton.c create mode 100644 samples/server/notify/services.xml create mode 100644 samples/server/sg_math/Makefile.am create mode 100644 samples/server/sg_math/add.c create mode 100644 samples/server/sg_math/add.h create mode 100644 samples/server/sg_math/add_skeleton.c create mode 100644 samples/server/sg_math/div.c create mode 100644 samples/server/sg_math/div.h create mode 100644 samples/server/sg_math/div_skeleton.c create mode 100644 samples/server/sg_math/mul.c create mode 100644 samples/server/sg_math/mul.h create mode 100644 samples/server/sg_math/mul_skeleton.c create mode 100644 samples/server/sg_math/services.xml create mode 100644 samples/server/sg_math/sg_math.mk create mode 100644 samples/server/sg_math/sub.c create mode 100644 samples/server/sg_math/sub.h create mode 100644 samples/server/sg_math/sub_skeleton.c create mode 100644 samples/server/version/Makefile.am create mode 100644 samples/server/version/services.xml create mode 100644 samples/server/version/version.c create mode 100644 samples/server/version/version.h create mode 100644 samples/server/version/version_skel.c create mode 100644 samples/user_guide/Makefile.am create mode 100644 samples/user_guide/clients/Makefile.am create mode 100644 samples/user_guide/clients/echo_blocking.c create mode 100644 samples/user_guide/clients/echo_blocking.mk create mode 100644 samples/user_guide/clients/echo_blocking_addr.c create mode 100644 samples/user_guide/clients/echo_blocking_addr.mk create mode 100644 samples/user_guide/clients/echo_blocking_auth.c create mode 100644 samples/user_guide/clients/echo_blocking_auth.mk create mode 100644 samples/user_guide/clients/echo_blocking_dual.c create mode 100644 samples/user_guide/clients/echo_blocking_dual.mk create mode 100644 samples/user_guide/clients/echo_blocking_soap11.c create mode 100644 samples/user_guide/clients/echo_blocking_soap11.mk create mode 100644 samples/user_guide/clients/echo_non_blocking.c create mode 100644 samples/user_guide/clients/echo_non_blocking.mk create mode 100644 samples/user_guide/clients/echo_non_blocking_dual.c create mode 100644 samples/user_guide/clients/echo_non_blocking_dual.mk create mode 100644 samples/user_guide/clients/echo_rest.c create mode 100644 samples/user_guide/clients/echo_rest.mk create mode 100644 samples/user_guide/clients/echo_util.c create mode 100644 samples/user_guide/clients/echo_util.h (limited to 'samples') diff --git a/samples/AUTHORS b/samples/AUTHORS new file mode 100644 index 0000000..1dcb019 --- /dev/null +++ b/samples/AUTHORS @@ -0,0 +1,26 @@ +Developers +---------- +Samisa Abeysinghe +Dushshantha Chandradasa +Chris Darroch +Senaka Fernando +Paul Fremantle +Dimuthu Gamage +Sahan Gamage +Lahiru Gunathilake +Nandika Jayawardana +Supun Kamburugamuva +Kaushalye Kapuruge +Damitha Kumarage +Danushka Menikkumbura +Bill Mitchell +Diluka Moratuwage +Dumindu Pallewela +Milinda Pathirage +Manjula Peiris +Dinesh Premalal +Sanjaya Rathnaweera +Davanum Srinivas +Selvaratnam Uthaiyashankar +Sanjiva Weerawarana +Nabeel Yoosuf diff --git a/samples/COPYING b/samples/COPYING new file mode 100644 index 0000000..4a67574 --- /dev/null +++ b/samples/COPYING @@ -0,0 +1,203 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + diff --git a/samples/ChangeLog b/samples/ChangeLog new file mode 100644 index 0000000..dab96de --- /dev/null +++ b/samples/ChangeLog @@ -0,0 +1,215 @@ +Axis2/C (1.6.0) + * XPath support for Axiom XML object model + * CGI support + * Improvements to MTOM to send, receive very large attachments + * Improvements to AMQP transport + * Improvemnets to WSDL2C codegen tool + * Many bug fixes. + * Memory leak fixes + +Axis2/C (1.5.0) + * AMQP Transport support with Apache Qpid. (At an experimental stage. Not working under Windows. Please refer the INSTALL file to build this) + * Modifications to IIS Module to support IIS 6 & 7 + * Added a JScript file to automate IIS module registry configuration + * Improved the in-only message handling + * Specifying the MEP in the services.xml for non in-out messages made mandatory + * Improvements to Guthtila for better performance + * Improvements to TCPMon tool + * Memory leak fixes + * Bug fixes + +Axis2/C (1.4.0) + * Fixed library version numbering + * Made Guththila as default XML parser +-- Axis2/C team Mon,5 May 2008 + +Axis2/C (1.3.0) + * Fixed a bug on version numbering + * List Axis2/C dependencies licensing in LICENSE file + * Add relevant copyright notices to NOTICE file + * Digest Authentication Support + * Proxy Authentication Support + * Enhanced REST support + * Ability to insert xml declaration on outgoing payloads + * MTOM support with libcurl + * Improvements to TCPMon Tool + * Improvements to Test Coverage + * Improvements to API docs + * Improvements to CA certificate validation mechanisms on SSL Transport + * Improvements to Neethi + * Fixed issue in HTTP GET on mod_axis2 + * Major Improvements to Guththila Parser + * Improvements to libcurl based sender + * Creation of a FAQ list + * Improvements to Axis2/C documentation + * Added Documentation on Archive Based Deployment + * Fixes for IIS module + * Removed dependency in util for the Axis2/C core + * Ability to access transport headers at the service level (for RESTful services) + * uint64_t and int64_t support at util layer and codegen level + * Removed zlib dependencies when Archive Based Deployment model is disabled + * Signal Handling in Windows + * Removed over 99% of the warnings found on Windows + * Increased build speed on Windows with nmake. + * Improvements to Windows build system + * Extensions to client API to support HTTP/Proxy Authentication + * Memory leak fixes + * Many bug fixes + +-- Axis2/C team Fri, 29 February 2008 +Axis2/C (1.2.0) + * Improvements to Java tool, WSDL2C, that generates C code + * Improvment to Apache2 module so that it + * Create a shared memory global pool + * create context hierarchy in the global pool + enabling it to have true application level scope. + * Improved Policy + * Improvements to thread environment + * Improvements to error handling + * Memory leak fixes + * Many bug fixes + +-- Axis2/C team Mon, 17 January 2008 +Axis2/C (1.1.0) + * WS-Policy implementation + * TCP Transport + * Improvements to Guththila parser to improve performance + * Improvements to Java tool, WSDL2C, that generates C code + * Basic HTTP Authentication + * Memory leak fixes + * Many bug fixes + +-- Axis2/C team Mon, 24 September 2007 + +Axis2/C (1.0.0) + * Many Bug Fixes + * IIS module for server side + * libcurl based client transport + * Improvements to overall API to make it more user friendly, stable and binary compatible + * Transport proxy support + * Memory leak fixes +-- Axis2/C team Mon, 30 April 2007 + +Axis2/C (0.96) + * Major Memory leak fixes + * Many Bug Fixes + * Improvement to REST processing + * Improvement to SOAP-Fault processing + * Improvement to mod_axis2 library (plugged with apr pools) + * Visual Studio 7.0 project +-- Axis2/C team Thu, 19 December 2006 + +Axis2/C (0.95) + * Major Memory leak fixes + * Many Bug Fixes + * Improved Documentation +-- Axis2/C team Thu, 26 October 2006 + +Axis2/C (0.94) + * Guththila pull parser support + * WSDL2C code generation tool + * TCP Monitor - C implementation + * Major Memory leak fixes + * Fixes to code generation with Java Tool + * Many Bug Fixes +-- Axis2/C team Tue, 3 October 2006 + +Axis2/C (0.93) + * REST support for HTTP GET case + * XML Schema implementation + * Woden/C implementation that supports both WSDL 1.1 and WSDL 2.0 + * Dynamic client invocation (given a WSDL, consume services dynamically) + * Numerous improvements to API and API documentation + * Many bug fixes, especially, many paths of execution previously untouched were tested along with Sandesha2/C implementation +-- Axis2/C team Thu, 31 August 2006 + +Axis2/C (0.92) + * Completed MTOM implementation with multiple attachment support and non-optimize + * Completed service client API with send robust and fire and forget + * Added "message" to description hierarchy + * Archive based deployment Model (for services and modules) + * Code generation for WSDL using Java WSDL2Code tool + * ADB support (with Java WSDL2C tool) + * WS-Security usernameToken support + * Initial implementation of the XML Schema parser (To be used in WSDL parser and REST support) + * Initial implementation of WSDL parser (To be used in dynamic invocation) + * Changed double pointer environment parameters into pointer parameters + to improve efficiency + -- Axis2/C team Fri, 16 June 2006 + +Axis2/C (0.91) + + * Full Addressing 1.0 support + * Improved fault handling model + * SSL client transport + * MTOM implementation + * Implementation of easy to use service client and operation client APIs for client side programming + * REST support (POST case) + * Module version support + * Service groups + * Numerous bug fixes since last release + -- Axis2/C team Mon, 15 May 2006 + + +Axis2/C (0.90) + + * Minimal memory leaks + * Apache2 module working in Windows + * More samples and tests + * WSDL Object Model built based on the proposed WSDL 2.0 Component model + * Dynamic Invocation + * Numerous bug fixes since last release + -- Axis2/C team Fri, 31 Mar 2006 + + +Axis2/C (M0.5) + + * Improving code quality by fixing memory leaks and reviewing the code + * Apache2 integration + * More samples and tests + * Initial documentation(User guide, Developer Guide and Installation Guide) + * Numerous bug fixes since last release + -- Axis2/C team Fri, 10 Mar 2006 + + +Axis2/C (M0.4) + + * Threading support and threaded simple axis server + * Module loading support + * Addressing module and addressing based dispatching + * HTTP chunking support + * Improved logging mechanism + * Ability to build and run on Windows platform + -- Axis2/C team Fri, 17 Feb 2006 + + +Axis2/C (M0.3) + + * Core engine in place with deployment, description and context hiarachies and http transport support + * Soap processing support + * Simple http server + * Client API implementation + * Couple of working service and client samples + -- Axis2/C team Thu, 02 Feb 2006 + + +Axis2/C (M0.2) + + * Improved OM module + * libxml2 parser support + * PHP binding for OM module + * Some test cases for PHP binding + * Many memory leaks fixes + -- Axis2/C team Thu, 08 Dec 2005 + + +Axis2/C (M0.1) + + * Initial release + + * OM module + * Guththila pull parser support + * libxml2 parser support(only reader is supported as of now) + * doxygen documentation support + * A sample demonstrating how to use OM + -- Axis2/C team Fri, 25 Nov 2005 diff --git a/samples/INSTALL b/samples/INSTALL new file mode 100644 index 0000000..72f0cc3 --- /dev/null +++ b/samples/INSTALL @@ -0,0 +1,14 @@ +Getting Axis2/C Samples Source Working on Linux +============================================= +Build the source +This can be done using the following command sequence: + ./configure + make + make install + use './configure --help' for options + +NOTE: If you don't provide a --prefix configure option, it will by default +install into /usr/local/axis2c/samples directory. + + + diff --git a/samples/LICENSE b/samples/LICENSE new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/samples/LICENSE @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/samples/Makefile.am b/samples/Makefile.am new file mode 100644 index 0000000..b66b5af --- /dev/null +++ b/samples/Makefile.am @@ -0,0 +1,8 @@ +SUBDIRS = server client user_guide mtom_caching_callback mtom_sending_callback + +dist-hook: + rm -rf `find $(distdir)/ -type d -name .svn` + rm -rf `find $(distdir)/ -type d -name .deps` + rm -rf `find $(distdir)/ -type d -name .libs` + +EXTRA_DIST=codegen autogen.sh build.sh diff --git a/samples/NEWS b/samples/NEWS new file mode 100644 index 0000000..ef04f57 --- /dev/null +++ b/samples/NEWS @@ -0,0 +1,97 @@ +Apache Axis2/C Team is pleased to announce the release of Apache Axis2/C +version 1.6.0. + +You can download this release from http://ws.apache.org/axis2/c/download.cgi + +Key Features +============ + + 1. Support for one-way messaging (In-Only) and + request response messaging (In-Out) + + 2. Client APIs : Easy to use service client API and + more advanced operation client API + + 3. Transports supported : HTTP + * Inbuilt HTTP server called simple axis server + * Apache2 httpd module called mod_axis2 for server side + * IIS module for server side. Supports IIS 5.1, 6 and 7. + * Client transport with ability to enable SSL support + * Basic HTTP Authentication + * Digest HTTP Authentication + * libcurl based client transport + * CGI interface + + 4. Transports supported : HTTPS + * HTTPS Transport implementation using OpenSSL + + 5. Transports supported : TCP + * for both client and server side + + 6. Transports supported : AMQP + * AMQP Transport implementation using Apache Qpid + * Available only in Linux platforms. + * At an experimental stage. Please refer the INSTALL file to build this. + + 7. Transport proxy support (HTTP) + * Proxy Authentication (Basic/Digest) + + 8. Module architecture, mechanism to extend the SOAP processing model. + + 9. WS-Addressing support, both the submission (2004/08) and + final (2005/08) versions, implemented as a module. + + 10. MTOM/XOP support. + + 11. AXIOM, an XML object model optimized for SOAP 1.1/1.2 messages; + This has complete XML infoset support. + + 12. XPath support for Axiom XML Object model + + 13. XML parser abstraction + * Libxml2 wrapper + * Guththila pull parser support + + 14. Both directory based and archive based deployment models for deploying + services and modules + + 15. Description hierarchy providing access to static data of Axis2/C runtime + (configuration, service groups, services, operations and messages) + + 16. Context hierarchy providing access to dynamic + Axis2/C runtime information (corresponding contexts to map to + each level of description hierarchy) + + 17. Message receiver abstraction + * Inbuilt raw XML message receiver + + 18. Code generation tool for stub and skeleton generation for a given + WSDL (based on Java tool) + * Axis Data Binding (ADB) support + + 19. REST support (more POX like) using HTTP POST, GET, HEAD, PUT and DELETE + * Support for RESTful Services + + 20. Comprehensive documentation + * Axis2/C Manual + + 21. WS-Policy implementation called Neethi/C, with WS-SecurityPolicy extension + + +Major Changes Since Last Release +================================ + + 1. XPath support for Axiom XML object model + 2. CGI support + 3. Improvements to MTOM to send, receive very large attachments + 4. Improvements to AMQP transport + 5. Many bug fixes. + 6. Memory leak fixes + +We welcome your early feedback on this implementation. + +Thanks for your interest in Axis2/C !!! + +-- Apache Axis2/C Team -- + + diff --git a/samples/README b/samples/README new file mode 100644 index 0000000..0471d96 --- /dev/null +++ b/samples/README @@ -0,0 +1,51 @@ + + Apache Axis2/C Samples + ------------------------ + + What Is It? + ----------- + + This package consists the samples of Apache Axis2/C. + + As a project of the Apache Software Foundation, the + developers aim to collaboratively develop and maintain a robust, + commercial-grade, standards-based Web services stack implementation with + freely available source code. + + The Latest Version + ------------------ + + You can get the latest svn checkout of Apache Axis2/C samples from + + https://svn.apache.org/repos/asf/webservices/axis2/trunk/c/samples + + Installation + ------------ + + Please see the file called INSTALL. + + Licensing + --------- + + Please see the file called LICENSE. + + Contacts + -------- + + o If you want freely available support for using Apache Axis2/C samples please + join the Apache Axis2/C user community by subscribing to users mailing + list, axis-c-user@ws.apache.org' as described at + http://ws.apache.org/axis2/c/mail-lists.html + + o If you have a bug report for Apache Axis2/C samples please log-in and create a JIRA issue + at http://issues.apache.org/jira/browse/AXIS2C + + o If you want to participate actively in developing Apache Axis2/C samples please + subscribe to the `axis-c-dev@ws.apache.org' mailing list as described at + http://ws.apache.org/axis2/c/mail-lists.html + + Acknowledgements + ---------------- + + Apache Axis2/C samples rely heavily on the use of autoconf and libtool to provide + a build environment. diff --git a/samples/autogen.sh b/samples/autogen.sh new file mode 100755 index 0000000..c0d09b3 --- /dev/null +++ b/samples/autogen.sh @@ -0,0 +1,51 @@ +#!/bin/bash +echo -n 'Running libtoolize...' +if [ `uname -s` = Darwin ] +then + LIBTOOLIZE=glibtoolize +else + LIBTOOLIZE=libtoolize +fi + +if $LIBTOOLIZE --force > /dev/null 2>&1; then + + echo 'done.' +else + echo 'failed.' + exit 1 +fi + + +echo -n 'Running aclocal...' +if aclocal > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running autoheader...' +if autoheader > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running autoconf...' +if autoconf > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running automake...' +if automake --add-missing > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo 'done' diff --git a/samples/build.sh b/samples/build.sh new file mode 100755 index 0000000..9fe3d7d --- /dev/null +++ b/samples/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +./autogen.sh + +./configure --prefix=${AXIS2C_HOME} +make -j 10 +make install + diff --git a/samples/client/Makefile.am b/samples/client/Makefile.am new file mode 100644 index 0000000..5e285b0 --- /dev/null +++ b/samples/client/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = echo math google notify mtom yahoo amqp version mtom_callback +EXTRA_DIST= Makefile.am diff --git a/samples/client/amqp/Makefile.am b/samples/client/amqp/Makefile.am new file mode 100644 index 0000000..10429ae --- /dev/null +++ b/samples/client/amqp/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = echo notify mtom diff --git a/samples/client/amqp/echo/Makefile.am b/samples/client/amqp/echo/Makefile.am new file mode 100644 index 0000000..b348c63 --- /dev/null +++ b/samples/client/amqp/echo/Makefile.am @@ -0,0 +1,36 @@ +prgbindir = $(prefix)/samples/bin/amqp + +prgbin_PROGRAMS = echo_blocking \ + echo_non_blocking \ + echo_blocking_addr \ + echo_blocking_dual \ + echo_non_blocking_dual \ + echo_blocking_soap11 + + +echo_blocking_SOURCES = echo_blocking.c echo_util.c +echo_non_blocking_SOURCES = echo_non_blocking.c echo_util.c +echo_blocking_addr_SOURCES = echo_blocking_addr.c echo_util.c +echo_blocking_dual_SOURCES = echo_blocking_dual.c echo_util.c +echo_non_blocking_dual_SOURCES = echo_non_blocking_dual.c echo_util.c +echo_blocking_soap11_SOURCES = echo_blocking_soap11.c echo_util.c + +LINK_FLAGS = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + $(GUTHTHILA_LIBS) + +echo_blocking_LDADD = $(LINK_FLAGS) +echo_non_blocking_LDADD = $(LINK_FLAGS) +echo_blocking_addr_LDADD = $(LINK_FLAGS) +echo_blocking_dual_LDADD = $(LINK_FLAGS) +echo_non_blocking_dual_LDADD = $(LINK_FLAGS) +echo_blocking_soap11_LDADD = $(LINK_FLAGS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=echo_util.h diff --git a/samples/client/amqp/echo/echo_blocking.c b/samples/client/amqp/echo/echo_blocking.c new file mode 100644 index 0000000..d21b2bb --- /dev/null +++ b/samples/client/amqp/echo/echo_blocking.c @@ -0,0 +1,124 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main (int argc, char **argv) +{ + const axutil_env_t* env = NULL; + const axis2_char_t* address = NULL; + axis2_endpoint_ref_t* endpoint_ref = NULL; + axis2_options_t* options = NULL; + const axis2_char_t* client_home = NULL; + axis2_svc_client_t* svc_client = NULL; + axiom_node_t* payload = NULL; + axiom_node_t* ret_node = NULL; + + /* Set up the environment */ + env = axutil_env_create_all ("echo_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + + if (axutil_strcmp (address, "-h") == 0) + { + printf ("Usage : %s [endpoint_url]\n", argv[0]); + printf ("use -h for help\n"); + + return 0; + } + + printf ("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create (env, address); + + /* Setup options */ + options = axis2_options_create (env); + axis2_options_set_to (options, env, endpoint_ref); + + /* Set up deploy folder */ + client_home = AXIS2_GETENV ("AXIS2C_HOME"); + if (!client_home || !strcmp (client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create (env, client_home); + if (!svc_client) + { + printf ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE (env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options (svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc (env); + + /* Send request and get response */ + ret_node = axis2_svc_client_send_receive (svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string (ret_node, env); + if (om_str) + { + printf ("\nReceived OM : %s\n", om_str); + AXIS2_FREE (env->allocator, om_str); + } + + printf ("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE (env->error)); + + printf ("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free (svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free ((axutil_env_t*)env); + env = NULL; + } + + return 0; +} + + diff --git a/samples/client/amqp/echo/echo_blocking_addr.c b/samples/client/amqp/echo/echo_blocking_addr.c new file mode 100644 index 0000000..1c0383c --- /dev/null +++ b/samples/client/amqp/echo/echo_blocking_addr.c @@ -0,0 +1,132 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_blocking_addr_amqp.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/client/amqp/echo/echo_blocking_dual.c b/samples/client/amqp/echo/echo_blocking_dual.c new file mode 100644 index 0000000..2d20ad0 --- /dev/null +++ b/samples/client/amqp/echo/echo_blocking_dual.c @@ -0,0 +1,142 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_endpoint_ref_t *reply_to = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_blocking_dual_amqp.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE); + + /* Seperate listner needs addressing, hence addressing stuff in options */ + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + reply_to = + axis2_endpoint_ref_create(env, + "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__"); + axis2_options_set_reply_to(options, env, reply_to); + + axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + AXIS2_SLEEP(1); + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/client/amqp/echo/echo_blocking_soap11.c b/samples/client/amqp/echo/echo_blocking_soap11.c new file mode 100644 index 0000000..4281e14 --- /dev/null +++ b/samples/client/amqp/echo/echo_blocking_soap11.c @@ -0,0 +1,135 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + axutil_string_t *soap_action = NULL; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_blocking_soap11_amqp.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_soap_version(options, env, AXIOM_SOAP11); + soap_action = + axutil_string_create(env, + "http://ws.apache.org/axis2/c/samples/echo/soap_action"); + axis2_options_set_soap_action(options, env, soap_action); + axutil_string_free(soap_action, env); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/client/amqp/echo/echo_non_blocking.c b/samples/client/amqp/echo/echo_non_blocking.c new file mode 100644 index 0000000..9846977 --- /dev/null +++ b/samples/client/amqp/echo/echo_non_blocking.c @@ -0,0 +1,217 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +/* my on_complete callback function */ +axis2_status_t AXIS2_CALL +echo_callback_on_complete (struct axis2_callback* callback, + const axutil_env_t* env); + +/* my on_error callback function */ +axis2_status_t AXIS2_CALL +echo_callback_on_error (struct axis2_callback* callback, + const axutil_env_t* env, + int exception); + +/* to check whether the callback is completed */ +int isComplete = 0; + +int +main(int argc, char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axis2_callback_t *callback = NULL; + int count = 0; + + /* Set up the environment */ + env = axutil_env_create_all ("echo_non_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + + if (axutil_strcmp (address, "-h") == 0) + { + printf ("Usage : %s [endpoint_url]\n", argv[0]); + printf ("use -h for help\n"); + + return 0; + } + + printf ("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create (env, address); + + /* Setup options */ + options = axis2_options_create (env); + axis2_options_set_to (options, env, endpoint_ref); + + /* Set up deploy folder */ + client_home = AXIS2_GETENV ("AXIS2C_HOME"); + if (!client_home || !strcmp (client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create (env, client_home); + if (!svc_client) + { + printf ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE (env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options (svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc (env); + + /* Create the callback object with default on_complete and on_error + callback functions */ + callback = axis2_callback_create (env); + + /* Set our on_complete fucntion pointer to the callback object */ + axis2_callback_set_on_complete (callback, echo_callback_on_complete); + + /* Set our on_error function pointer to the callback object */ + axis2_callback_set_on_error (callback, echo_callback_on_error); + + /* Send request */ + axis2_svc_client_send_receive_non_blocking (svc_client, env, + payload, callback); + + /*Wait till callback is complete. Simply keep the parent thread running + until our on_complete or on_error is invoked */ + while (count < 30) + { + if (isComplete) + { + /* We are done with the callback */ + break; + } + + AXIS2_SLEEP (1); + count++; + } + + if (!(count < 30)) + { + printf ("\necho client invoke FAILED. Counter timed out.\n"); + } + + if (svc_client) + { + axis2_svc_client_free (svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free ((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_complete(struct axis2_callback* callback, + const axutil_env_t* env) +{ + + /** SOAP response has arrived here; get the soap envelope + from the callback object and do whatever you want to do with it */ + + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_node_t *ret_node = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + soap_envelope = axis2_callback_get_envelope (callback, env); + + if (!soap_envelope) + { + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE (env->error)); + printf ("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + ret_node = axiom_soap_envelope_get_base_node (soap_envelope, env); + + if (!ret_node) + { + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE (env->error)); + + printf ("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string (ret_node, env); + if (om_str) + { + printf ("\nReceived OM : %s\n", om_str); + AXIS2_FREE (env->allocator, om_str); + } + + printf ("\necho client invoke SUCCESSFUL!\n"); + } + } + + isComplete = 1; + return status; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_error (struct axis2_callback* callback, + const axutil_env_t* env, + int exception) +{ + + /** take necessary action on error */ + printf ("\necho client invike FAILED. Error code:%d ::%s", exception, + AXIS2_ERROR_GET_MESSAGE (env->error)); + + isComplete = 1; + + return AXIS2_SUCCESS; +} + + diff --git a/samples/client/amqp/echo/echo_non_blocking_dual.c b/samples/client/amqp/echo/echo_non_blocking_dual.c new file mode 100644 index 0000000..b1ce5a1 --- /dev/null +++ b/samples/client/amqp/echo/echo_non_blocking_dual.c @@ -0,0 +1,235 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +#define MAX_COUNT 10 + +/* my on_complete callback function */ +axis2_status_t AXIS2_CALL echo_callback_on_complete( + struct axis2_callback * callback, + const axutil_env_t * env); + +/* my on_error callback function */ +axis2_status_t AXIS2_CALL echo_callback_on_error( + struct axis2_callback *callback, + const axutil_env_t * env, + int exception); + +/* to check whether the callback is completed */ +int isComplete = 0; + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_endpoint_ref_t *reply_to = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axis2_callback_t *callback = NULL; + int count = 0; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_non_blocking_dual_amqp.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE); + + /* Seperate listner needs addressing, hence addressing stuff in options */ + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + reply_to = + axis2_endpoint_ref_create(env, + "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__"); + axis2_options_set_reply_to(options, env, reply_to); + + axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + /*axis2_svc_client_engage_module(svc_client, env, "sandesha2"); */ + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Create the callback object with default on_complete and on_error + callback functions */ + callback = axis2_callback_create(env); + + /* Set our on_complete fucntion pointer to the callback object */ + axis2_callback_set_on_complete(callback, echo_callback_on_complete); + + /* Set our on_error function pointer to the callback object */ + axis2_callback_set_on_error(callback, echo_callback_on_error); + + /* Send request */ + axis2_svc_client_send_receive_non_blocking(svc_client, env, + payload, callback); + + /** Wait till callback is complete. Simply keep the parent thread running + until our on_complete or on_error is invoked */ + while (count < MAX_COUNT) + { + if (isComplete) + { + /* We are done with the callback */ + break; + } + + AXIS2_SLEEP(1); + count++; + } + + if (!(count < MAX_COUNT)) + { + printf("\necho client invoke FAILED. Counter timed out.\n"); + } + + if (svc_client) + { + AXIS2_SLEEP(1); + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_complete( + struct axis2_callback * callback, + const axutil_env_t * env) +{ + + /** SOAP response has arrived here; get the soap envelope + from the callback object and do whatever you want to do with it */ + + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_node_t *ret_node = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + soap_envelope = axis2_callback_get_envelope(callback, env); + + if (!soap_envelope) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env); + + if (!ret_node) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + printf("\nReceived OM : %s\n", om_str); + printf("\necho client invoke SUCCESSFUL!\n"); + } + } + isComplete = 1; + return status; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_error( + struct axis2_callback * callback, + const axutil_env_t * env, + int exception) +{ + + /** take necessary action on error */ + printf("\nEcho client invoke FAILED. Error code:%d ::%s", exception, + AXIS2_ERROR_GET_MESSAGE(env->error)); + isComplete = 1; + return AXIS2_SUCCESS; +} diff --git a/samples/client/amqp/echo/echo_util.c b/samples/client/amqp/echo/echo_util.c new file mode 100644 index 0000000..c49d42d --- /dev/null +++ b/samples/client/amqp/echo/echo_util.c @@ -0,0 +1,47 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" + +/* build SOAP request message content using OM */ +axiom_node_t* +build_om_payload_for_echo_svc (const axutil_env_t* env) +{ + axiom_node_t* echo_om_node = NULL; + axiom_element_t* echo_om_ele = NULL; + axiom_node_t* text_om_node = NULL; + axiom_element_t* text_om_ele = NULL; + axiom_namespace_t* ns1 = NULL; + axis2_char_t* om_str = NULL; + + ns1 = axiom_namespace_create (env, "http://ws.apache.org/axis2/services/echo", + "ns1"); + echo_om_ele = axiom_element_create (env, NULL, "echoString", ns1, &echo_om_node); + text_om_ele = axiom_element_create (env, echo_om_node, "text", NULL, &text_om_node); + axiom_element_set_text (text_om_ele, env, "Hello World!", text_om_node); + + om_str = axiom_node_to_string (echo_om_node, env); + if (om_str) + printf ("\nSending OM : %s\n", om_str); + + AXIS2_FREE (env->allocator, om_str); + + return echo_om_node; +} + + diff --git a/samples/client/amqp/echo/echo_util.h b/samples/client/amqp/echo/echo_util.h new file mode 100644 index 0000000..c932efb --- /dev/null +++ b/samples/client/amqp/echo/echo_util.h @@ -0,0 +1,54 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIS2_UG_ECHO_UTIL_H +#define AXIS2_UG_ECHO_UTIL_H + +#include +#include + +axiom_node_t* build_om_payload_for_echo_svc (const axutil_env_t * env); + +#endif + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIS2_UG_ECHO_UTIL_H +#define AXIS2_UG_ECHO_UTIL_H + +#include +#include + +axiom_node_t* build_om_payload_for_echo_svc (const axutil_env_t * env); + +#endif diff --git a/samples/client/amqp/mtom/Makefile.am b/samples/client/amqp/mtom/Makefile.am new file mode 100644 index 0000000..fa2f51a --- /dev/null +++ b/samples/client/amqp/mtom/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = resources + +prgbindir = $(prefix)/samples/bin/amqp + +prgbin_PROGRAMS = mtom + +mtom_SOURCES = mtom_client.c + +mtom_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ diff --git a/samples/client/amqp/mtom/mtom_client.c b/samples/client/amqp/mtom/mtom_client.c new file mode 100644 index 0000000..da87e1b --- /dev/null +++ b/samples/client/amqp/mtom/mtom_client.c @@ -0,0 +1,259 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * image_name, + const axis2_char_t * to_save_name, + axis2_bool_t optimized); + +int +process_response_node( + const axutil_env_t * env, + axiom_node_t *node, + const axis2_char_t * to_save_name); + + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + const axis2_char_t *image_name = "resources/axis2.jpg"; + const axis2_char_t *to_save_name = "test.jpg"; + axis2_bool_t optimized = AXIS2_TRUE; + + /* Set up the environment */ + env = axutil_env_create_all("mtom_amqp.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of mtom service */ + address = "amqp://localhost:5672/axis2/services/mtom"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf + ("Usage : %s [endpoint_url] [image_name] [to_save_name] [do_not_optimize]\n", + argv[0]); + printf("use -h for help\n"); + return 0; + } + if (argc > 2) + image_name = argv[2]; + if (argc > 3) + to_save_name = argv[3]; + if (argc > 4) + optimized = AXIS2_FALSE; + + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/mtomSample"); + + axis2_options_set_soap_version(options, env, AXIOM_SOAP11); + + if(optimized) + { + axis2_options_set_enable_mtom(options, env, AXIS2_TRUE); + } + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = + build_om_programatically(env, image_name, to_save_name, optimized); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE) + { + printf("\nRecieved Fault : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + else + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + printf("\nmtom client invoke SUCCESSFUL!\n"); + process_response_node(env, ret_node, to_save_name); + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("\nmtom client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; + +} + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * image_name, + const axis2_char_t * to_save_name, + axis2_bool_t optimized) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *image_om_node = NULL; + axiom_element_t *image_om_ele = NULL; + axiom_node_t *file_om_node = NULL; + axiom_element_t *file_om_ele = NULL; + axiom_node_t *data_om_node = NULL; + axiom_text_t *data_text = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + axiom_data_handler_t *data_handler = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node); + + file_om_ele = + axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node); + axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node); + + image_om_ele = + axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node); + + data_handler = axiom_data_handler_create(env, image_name, "image/jpeg"); + data_text = + axiom_text_create_with_data_handler(env, image_om_node, data_handler, + &data_om_node); + axiom_text_set_optimize(data_text, env, optimized); + om_str = axiom_node_to_string(mtom_om_node, env); + if (om_str) + { + printf("%s", om_str); + AXIS2_FREE(env->allocator, om_str); + } + return mtom_om_node; +} + + +int +process_response_node( + const axutil_env_t * env, + axiom_node_t *node, + const axis2_char_t * to_save_name) +{ + axiom_node_t *res_om_node = NULL; + axiom_element_t *res_om_ele = NULL; + res_om_node = axiom_node_get_first_child(node, env); + + if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT) + {/** received mtom atttachment */ + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env); + data_handler = axiom_text_get_data_handler(axiom_text, env); + + /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/ + if(axiom_data_handler_get_cached(data_handler, env)) + { + printf("Attachment is cached.\n"); + } + else + { + axiom_data_handler_set_file_name(data_handler, env, "test"); + axiom_data_handler_write_to(data_handler, env); + } + }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){ + res_om_ele = axiom_node_get_data_element(res_om_node, env); + printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node)); + } + + return 0; +} + + diff --git a/samples/client/amqp/mtom/resources/Makefile.am b/samples/client/amqp/mtom/resources/Makefile.am new file mode 100644 index 0000000..2d60ebd --- /dev/null +++ b/samples/client/amqp/mtom/resources/Makefile.am @@ -0,0 +1,5 @@ +samplesdir = $(prefix)/samples/bin/amqp/resources + +samples_DATA = axis2.jpg + +EXTRA_DIST = axis2.jpg diff --git a/samples/client/amqp/mtom/resources/axis2.jpg b/samples/client/amqp/mtom/resources/axis2.jpg new file mode 100644 index 0000000..73371d8 Binary files /dev/null and b/samples/client/amqp/mtom/resources/axis2.jpg differ diff --git a/samples/client/amqp/notify/Makefile.am b/samples/client/amqp/notify/Makefile.am new file mode 100644 index 0000000..85cc43e --- /dev/null +++ b/samples/client/amqp/notify/Makefile.am @@ -0,0 +1,15 @@ +prgbindir = $(prefix)/samples/bin/amqp + +prgbin_PROGRAMS = notify + +notify_SOURCES = notify_client.c + +notify_LDADD = -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ diff --git a/samples/client/amqp/notify/notify_client.c b/samples/client/amqp/notify/notify_client.c new file mode 100644 index 0000000..f562a5c --- /dev/null +++ b/samples/client/amqp/notify/notify_client.c @@ -0,0 +1,152 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env); + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axis2_status_t status = AXIS2_FAILURE; + + /* Set up the environment */ + env = axutil_env_create_all("notify_amqp.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "amqp://localhost:5672/axis2/services/notify"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, "http://example.org/action/notify"); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_programatically(env); + + /* Send request */ + status = axis2_svc_client_send_robust(svc_client, env, payload); + + if (status == AXIS2_SUCCESS) + { + printf("\nnotify client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("notify client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env) +{ + axiom_node_t *notify_om_node = NULL; + axiom_element_t *notify_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *buffer = NULL; + + ns1 = axiom_namespace_create(env, "http://example.org/notify", "m"); + notify_om_ele = + axiom_element_create(env, NULL, "notify", ns1, ¬ify_om_node); + axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node); + + buffer = axiom_node_to_string(notify_om_node, env); + if (buffer) + { + printf("\nSending OM node in XML : %s \n", buffer); + AXIS2_FREE(env->allocator, buffer); + } + + return notify_om_node; +} diff --git a/samples/client/echo/Makefile.am b/samples/client/echo/Makefile.am new file mode 100644 index 0000000..340e826 --- /dev/null +++ b/samples/client/echo/Makefile.am @@ -0,0 +1,18 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = echo +echo_SOURCES = echo.c + +echo_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=README.txt echo.mk diff --git a/samples/client/echo/README.txt b/samples/client/echo/README.txt new file mode 100644 index 0000000..e3284a5 --- /dev/null +++ b/samples/client/echo/README.txt @@ -0,0 +1,5 @@ +Client Sample -echo +------------------- + +This is a sample to help test addressing. +This sample works with echo service. diff --git a/samples/client/echo/echo.c b/samples/client/echo/echo.c new file mode 100644 index 0000000..94a0a20 --- /dev/null +++ b/samples/client/echo/echo.c @@ -0,0 +1,196 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +axiom_node_t *build_om_payload_for_echo_svc( + const axutil_env_t * env); + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + axiom_node_t *payload2 = NULL; + axiom_node_t *ret_node2 = NULL; + + /* Set up the environment */ + env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + { + if (axutil_strcmp(argv[1], "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", + argv[0]); + printf("use -h for help\n"); + return 0; + } + else + { + address = argv[1]; + } + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + printf("\nReceived OM : %s\n", om_str); + printf("\necho client invoke SUCCESSFUL!\n"); + + AXIS2_FREE(env->allocator, om_str); + ret_node = NULL; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + payload2 = build_om_payload_for_echo_svc(env); + ret_node2 = axis2_svc_client_send_receive(svc_client, env, payload2); + if (ret_node2) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node2, env); + if (om_str) + printf("\nReceived OM : %s\n", om_str); + printf("\necho client invoke SUCCESSFUL!\n"); + + AXIS2_FREE(env->allocator, om_str); + ret_node2 = NULL; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_payload_for_echo_svc( + const axutil_env_t * env) +{ + axiom_node_t *echo_om_node = NULL; + axiom_element_t *echo_om_ele = NULL; + axiom_node_t *text_om_node = NULL; + axiom_element_t *text_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/services/echo", + "ns1"); + echo_om_ele = + axiom_element_create(env, NULL, "echoString", ns1, &echo_om_node); + text_om_ele = + axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node); + axiom_element_set_text(text_om_ele, env, "Hello World!", text_om_node); + om_str = axiom_node_to_string(echo_om_node, env); + + if (om_str) + { + printf("\nSending OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + om_str = NULL; + } + return echo_om_node; +} diff --git a/samples/client/echo/echo.mk b/samples/client/echo/echo.mk new file mode 100644 index 0000000..fc9b65b --- /dev/null +++ b/samples/client/echo/echo.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo echo.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo.exe + + + + + diff --git a/samples/client/google/Makefile.am b/samples/client/google/Makefile.am new file mode 100644 index 0000000..b44e9b8 --- /dev/null +++ b/samples/client/google/Makefile.am @@ -0,0 +1,17 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = google +google_SOURCES = google_client.c + +google_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=README.txt google.mk diff --git a/samples/client/google/README.txt b/samples/client/google/README.txt new file mode 100644 index 0000000..de8e74e --- /dev/null +++ b/samples/client/google/README.txt @@ -0,0 +1,10 @@ +Client Sample- Google +--------------------- + +In order to run this sample, you need to get a Google license key. +Please visit http://www.google.com/apis/ for details on how to get a license key. + +Use the '-h' option with the sample to get help on command line options. +e.g. +./google -h + diff --git a/samples/client/google/google.mk b/samples/client/google/google.mk new file mode 100644 index 0000000..56fa2b1 --- /dev/null +++ b/samples/client/google/google.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:google.exe + + + + + diff --git a/samples/client/google/google_client.c b/samples/client/google/google_client.c new file mode 100644 index 0000000..05e9f33 --- /dev/null +++ b/samples/client/google/google_client.c @@ -0,0 +1,290 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +axiom_node_t *build_soap_body_content( + const axutil_env_t * env, + const axis2_char_t * operation, + const axis2_char_t * google_key, + const axis2_char_t * word_to_spell); + +void print_invalid_om( + const axutil_env_t * env, + axiom_node_t * ret_node); + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + + const axis2_char_t *google_key = NULL; + const axis2_char_t *word_to_spell = NULL; + const axis2_char_t *operation = NULL; + + operation = "doSpellingSuggestion"; + google_key = "00000000000000000000000000000000"; + word_to_spell = "salvasion"; + + /* Set up the environment */ + env = axutil_env_create_all("google_client.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of google service */ + address = "http://api.google.com/search/beta2"; + + if ((argc > 1) && (axutil_strcmp("-h", argv[1]) == 0)) + { + printf("\nUsage : %s [google_key] [word_to_spell] \n", argv[0]); + printf + ("\tgoogle_key Your Google license key. Default value won't work. You must use your key here.\n"); + printf + ("\tword_to_spell Word to be spelled by Google service. Default is %s\n", + word_to_spell); + printf + ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n"); + printf("\tUse -h for help\n"); + return 0; + } + + if (argc > 1) + google_key = argv[1]; + if (argc > 2) + word_to_spell = argv[2]; + if (argc > 3) + address = argv[3]; + + printf("Using endpoint : %s\n", address); + printf("\nInvoking operation %s with params %s and %s\n", operation, + google_key, word_to_spell); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_soap_version(options, env, AXIOM_SOAP11); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = + build_soap_body_content(env, operation, google_key, word_to_spell); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (axis2_svc_client_get_last_response_has_fault(svc_client, env)) + { + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axis2_char_t *fault_string = NULL; + + printf("\nResponse has a SOAP fault\n"); + soap_envelope = + axis2_svc_client_get_last_response_soap_envelope(svc_client, env); + if (soap_envelope) + { + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + } + + if (soap_body) + { + soap_fault = axiom_soap_body_get_fault(soap_body, env); + } + + if (soap_fault) + { + fault_string = axiom_node_to_string(axiom_soap_fault_get_base_node + (soap_fault, env), env); + printf("\nReturned SOAP fault: %s\n", fault_string); + AXIS2_FREE (env->allocator, fault_string); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return -1; + } + + if (ret_node) + { + if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT) + { + axis2_char_t *result = NULL; + axiom_element_t *result_ele = NULL; + axiom_node_t *ret_node1 = NULL; + + result_ele = + (axiom_element_t *) axiom_node_get_data_element(ret_node, env); + if (axutil_strcmp + (axiom_element_get_localname(result_ele, env), + "doSpellingSuggestionResponse") != 0) + { + print_invalid_om(env, ret_node); + return AXIS2_FAILURE; + } + + ret_node1 = axiom_node_get_first_element(ret_node, env); /*return */ + if (!ret_node1) + { + print_invalid_om(env, ret_node); + return AXIS2_FAILURE; + } + result_ele = + (axiom_element_t *) axiom_node_get_data_element(ret_node1, env); + result = axiom_element_get_text(result_ele, env, ret_node1); + printf("\nResult = %s\n", result); + } + else + { + print_invalid_om(env, ret_node); + return AXIS2_FAILURE; + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("Google client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +axiom_node_t * +build_soap_body_content( + const axutil_env_t * env, + const axis2_char_t * operation, + const axis2_char_t * google_key, + const axis2_char_t * word_to_spell) +{ + axiom_node_t *google_om_node = NULL; + axiom_element_t *google_om_ele = NULL; + axiom_node_t *text_om_node = NULL; + axiom_element_t *text_om_ele = NULL; + axiom_namespace_t *ns0 = NULL, + *ns1 = NULL, + *ns2 = NULL, + *ns3 = NULL; + axiom_attribute_t *attri1 = NULL; + axis2_char_t *buffer = NULL; + + ns0 = + axiom_namespace_create(env, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, + "soapenv"); + ns1 = axiom_namespace_create(env, "urn:GoogleSearch", "ns1"); + ns2 = + axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema-instance", + "xsi"); + ns3 = + axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema", "xsd"); + + attri1 = axiom_attribute_create(env, "encodingStyle", + "http://schemas.xmlsoap.org/soap/encoding/", + ns0); + + google_om_ele = + axiom_element_create(env, NULL, operation, ns1, &google_om_node); + axiom_element_add_attribute(google_om_ele, env, attri1, google_om_node); + axiom_element_declare_namespace(google_om_ele, env, google_om_node, ns2); + axiom_element_declare_namespace(google_om_ele, env, google_om_node, ns3); + + text_om_ele = + axiom_element_create(env, google_om_node, "key", NULL, &text_om_node); + attri1 = axiom_attribute_create(env, "type", "xsd:string", ns2); + axiom_element_add_attribute(text_om_ele, env, attri1, text_om_node); + axiom_element_set_text(text_om_ele, env, google_key, text_om_node); + + text_om_ele = + axiom_element_create(env, google_om_node, "phrase", NULL, + &text_om_node); + axiom_element_add_attribute(text_om_ele, env, attri1, text_om_node); + axiom_element_set_text(text_om_ele, env, word_to_spell, text_om_node); + + buffer = axiom_node_to_string(google_om_node, env); + printf("%s\n", buffer); + AXIS2_FREE (env->allocator, buffer); + return google_om_node; +} + +void +print_invalid_om( + const axutil_env_t * env, + axiom_node_t * ret_node) +{ + axis2_char_t *buffer = NULL; + buffer = axiom_node_get_data_element(ret_node, env); + printf("\nReceived OM as result : %s\n", buffer); +} diff --git a/samples/client/math/Makefile.am b/samples/client/math/Makefile.am new file mode 100644 index 0000000..8cca62e --- /dev/null +++ b/samples/client/math/Makefile.am @@ -0,0 +1,20 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = math +noinst_HEADERS = axis2_math_stub.h +math_SOURCES = axis2_math_stub.c \ + math_client.c + +math_LDADD = \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=math.mk diff --git a/samples/client/math/axis2_math_stub.c b/samples/client/math/axis2_math_stub.c new file mode 100644 index 0000000..366e159 --- /dev/null +++ b/samples/client/math/axis2_math_stub.c @@ -0,0 +1,193 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_math_stub.h" + +axis2_stub_t * +axis2_math_stub_create_with_endpoint_ref_and_client_home( + const axutil_env_t * env, + axis2_endpoint_ref_t * endpoint_ref, + axis2_char_t * client_home) +{ + axis2_stub_t *stub = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + stub = (axis2_stub_t *) + axis2_stub_create_with_endpoint_ref_and_client_home(env, endpoint_ref, + client_home); + if (!stub) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_populate_axis_service(stub, env); + return stub; +} + +void +axis2_populate_axis_service( + axis2_stub_t * stub, + const axutil_env_t * env) +{ + axis2_svc_client_t *svc_client = NULL; + axutil_qname_t *op_qname = NULL; + axis2_svc_t *svc = NULL; + axis2_op_t *op = NULL; + + /*Modifying the Service */ + svc_client = axis2_stub_get_svc_client(stub, env); + svc = axis2_svc_client_get_svc(svc_client, env); + + /*creating the operations */ + + op_qname = axutil_qname_create(env, "add", "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN); + axis2_svc_add_op(svc, env, op); + axutil_qname_free(op_qname, env); + + op_qname = axutil_qname_create(env, "sub", "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN); + axis2_svc_add_op(svc, env, op); + axutil_qname_free(op_qname, env); + + op_qname = axutil_qname_create(env, "mul", "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN); + axis2_svc_add_op(svc, env, op); + axutil_qname_free(op_qname, env); + + op_qname = axutil_qname_create(env, "div", "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN); + axis2_svc_add_op(svc, env, op); + axutil_qname_free(op_qname, env); +} + +axis2_stub_t * +axis2_math_stub_create_with_endpoint_uri_and_client_home( + const axutil_env_t * env, + const axis2_char_t * endpoint_uri, + const axis2_char_t * client_home) +{ + axis2_stub_t *stub = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + stub = (axis2_stub_t *) + axis2_stub_create_with_endpoint_uri_and_client_home(env, endpoint_uri, + client_home); + if (!stub) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + axis2_populate_axis_service(stub, env); + + return stub; +} + +/***************************Function implementation****************************/ + +axiom_node_t * +axis2_math_stub_add( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axutil_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = axis2_stub_get_svc_client(stub, env); + op_qname = axutil_qname_create(env, "add", "", NULL); + ret_node = + axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname, + node); + axutil_qname_free(op_qname, env); + + return ret_node; +} + +axiom_node_t * +axis2_math_stub_sub( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axutil_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = axis2_stub_get_svc_client(stub, env); + op_qname = axutil_qname_create(env, "sub", "", NULL); + ret_node = + axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname, + node); + + return ret_node; +} + +axiom_node_t * +axis2_math_stub_mul( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axutil_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = axis2_stub_get_svc_client(stub, env); + op_qname = axutil_qname_create(env, "mul", "", NULL); + ret_node = + axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname, + node); + + return ret_node; +} + +axiom_node_t * +axis2_math_stub_div( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axutil_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = axis2_stub_get_svc_client(stub, env); + op_qname = axutil_qname_create(env, "div", "", NULL); + ret_node = + axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname, + node); + + return ret_node; +} diff --git a/samples/client/math/axis2_math_stub.h b/samples/client/math/axis2_math_stub.h new file mode 100644 index 0000000..20497b5 --- /dev/null +++ b/samples/client/math/axis2_math_stub.h @@ -0,0 +1,86 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIS2_ECHO_STUB_H +#define AXIS2_ECHO_STUB_H + +/** + * @file axis2_math_stub.h + * @brief axis2 math stub interface + */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + axiom_node_t *axis2_math_stub_add( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node); + + axiom_node_t *axis2_math_stub_sub( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node); + + axiom_node_t *axis2_math_stub_mul( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node); + + axiom_node_t *axis2_math_stub_div( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node); + + /** + * populate services + */ + void axis2_populate_axis_service( + axis2_stub_t * stub, + const axutil_env_t * env); + + /** + * Creates axis2_stub struct + * @param endpoint reference + * @return pointer to newly created axis2_stub struct + */ + axis2_stub_t *axis2_math_stub_create_with_endpoint_ref_and_client_home( + const axutil_env_t * env, + axis2_endpoint_ref_t * endpoint_ref, + axis2_char_t * client_home); + + /** + * Creates axis2_stub struct + * @param endpoint uri + * @return pointer to newly created axis2_stub struct + */ + axis2_stub_t *axis2_math_stub_create_with_endpoint_uri_and_client_home( + const axutil_env_t * env, + const axis2_char_t * endpoint_uri, + const axis2_char_t * client_home); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_ECHO_STUB_H */ diff --git a/samples/client/math/math.mk b/samples/client/math/math.mk new file mode 100644 index 0000000..c82a342 --- /dev/null +++ b/samples/client/math/math.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:math.exe + + + + + diff --git a/samples/client/math/math_client.c b/samples/client/math/math_client.c new file mode 100644 index 0000000..5d783a7 --- /dev/null +++ b/samples/client/math/math_client.c @@ -0,0 +1,201 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_math_stub.h" +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * operation, + const axis2_char_t * param1, + const axis2_char_t * param2); + +int +main( + int argc, + char **argv) +{ + axis2_stub_t *stub = NULL; + axiom_node_t *node = NULL; + axis2_status_t status = AXIS2_FAILURE; + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + const axis2_char_t *client_home = NULL; + axiom_node_t *ret_node = NULL; + + const axis2_char_t *operation = "add"; + const axis2_char_t *param1 = "40"; + const axis2_char_t *param2 = "8"; + + env = axutil_env_create_all("math_blocking.log", AXIS2_LOG_LEVEL_TRACE); + + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + address = "http://localhost:9090/axis2/services/math"; + if (argc > 1) + operation = argv[1]; + if (axutil_strcmp(operation, "-h") == 0) + { + printf("Usage : %s [operation] [param1] [param2] [endpoint_url]\n", + argv[0]); + printf("use -h for help\n"); + printf("default operation add\n"); + printf("default param1 %s\n", param1); + printf("default param2 %s\n", param2); + printf("default endpoint_url %s\n", address); + printf + ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n"); + return 0; + } + if (argc > 2) + param1 = argv[2]; + if (argc > 3) + param2 = argv[3]; + if (argc > 4) + address = argv[4]; + + printf("Using endpoint : %s\n", address); + printf("\nInvoking operation %s with params %s and %s\n", operation, param1, + param2); + + node = build_om_programatically(env, operation, param1, param2); + stub = + axis2_math_stub_create_with_endpoint_uri_and_client_home(env, address, + client_home); + + /* create node and invoke math */ + if (stub) + { + ret_node = axis2_math_stub_add(stub, env, node); + } + + if (ret_node) + { + if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT) + { + axis2_char_t *result = NULL; + axiom_element_t *result_ele = + (axiom_element_t *) axiom_node_get_data_element(ret_node, env); + + result = axiom_element_get_text(result_ele, env, ret_node); + printf("\nResult = %s\n", result); + } + else + { + axiom_xml_writer_t *writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(env, writer); + + axiom_node_serialize(ret_node, env, om_output); + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, env); + printf("\nReceived invalid OM as result : %s\n", buffer); + if (buffer) + { + AXIS2_FREE(env->allocator, buffer); + buffer = NULL; + } + if (om_output) + { + axiom_output_free(om_output, env); + om_output = NULL; + } + axiom_xml_writer_free(writer, env); + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("math stub invoke FAILED!\n"); + } + + if (stub) + { + axis2_stub_free(stub, env); + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return status; +} + +axiom_node_t * +build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * operation, + const axis2_char_t * param1, + const axis2_char_t * param2) +{ + axiom_node_t *math_om_node = NULL; + axiom_element_t *math_om_ele = NULL; + axiom_node_t *text_om_node = NULL; + axiom_element_t *text_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/services/math", + "ns1"); + + math_om_ele = + axiom_element_create(env, NULL, operation, ns1, &math_om_node); + + text_om_ele = + axiom_element_create(env, math_om_node, "param1", NULL, &text_om_node); + axiom_element_set_text(text_om_ele, env, param1, text_om_node); + + text_om_ele = + axiom_element_create(env, math_om_node, "param2", NULL, &text_om_node); + axiom_element_set_text(text_om_ele, env, param2, text_om_node); + + xml_writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(env, xml_writer); + + axiom_node_serialize(math_om_node, env, om_output); + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env); + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n", + buffer); + if (om_output) + { + axiom_output_free(om_output, env); + om_output = NULL; + } + + return math_om_node; +} diff --git a/samples/client/math/services.xml b/samples/client/math/services.xml new file mode 100644 index 0000000..53c43e9 --- /dev/null +++ b/samples/client/math/services.xml @@ -0,0 +1,18 @@ + + math + + This is a testing service, named 'math' to test multiple operations in the same service + + + + + + + + + + + + + + diff --git a/samples/client/mtom/Makefile.am b/samples/client/mtom/Makefile.am new file mode 100644 index 0000000..df1a866 --- /dev/null +++ b/samples/client/mtom/Makefile.am @@ -0,0 +1,20 @@ +SUBDIRS=resources +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = mtom + +mtom_SOURCES = mtom_client.c + +mtom_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=mtom.mk diff --git a/samples/client/mtom/mtom.mk b/samples/client/mtom/mtom.mk new file mode 100644 index 0000000..01f0e3c --- /dev/null +++ b/samples/client/mtom/mtom.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:mtom.exe + + + + + diff --git a/samples/client/mtom/mtom_client.c b/samples/client/mtom/mtom_client.c new file mode 100644 index 0000000..070ee5b --- /dev/null +++ b/samples/client/mtom/mtom_client.c @@ -0,0 +1,271 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * image_name, + const axis2_char_t * to_save_name, + axis2_bool_t optimized); + +int +process_response_node( + const axutil_env_t * env, + axiom_node_t *node, + const axis2_char_t * to_save_name); + + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + const axis2_char_t *image_name = "resources/axis2.jpg"; + const axis2_char_t *to_save_name = "test.jpg"; + axis2_bool_t optimized = AXIS2_TRUE; + + /* Set up the environment */ + env = axutil_env_create_all("mtom.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of mtom service */ + address = "http://localhost:9090/axis2/services/mtom"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf + ("Usage : %s [endpoint_url] [image_name] [to_save_name] [do_not_optimize]\n", + argv[0]); + printf("use -h for help\n"); + return 0; + } + if (argc > 2) + image_name = argv[2]; + if (argc > 3) + to_save_name = argv[3]; + if (argc > 4) + optimized = AXIS2_FALSE; + + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/mtomSample"); + + axis2_options_set_soap_version(options, env, AXIOM_SOAP11); + + if(optimized) + { + axis2_options_set_enable_mtom(options, env, AXIS2_TRUE); + } + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = + build_om_programatically(env, image_name, to_save_name, optimized); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE) + { + printf("\nRecieved Fault : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + else + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + printf("\nmtom client invoke SUCCESSFUL!\n"); + process_response_node(env, ret_node, to_save_name); + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("\nmtom client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; + +} + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * image_name, + const axis2_char_t * to_save_name, + axis2_bool_t optimized) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *image_om_node = NULL; + axiom_element_t *image_om_ele = NULL; + axiom_node_t *file_om_node = NULL; + axiom_element_t *file_om_ele = NULL; + axiom_node_t *data_om_node = NULL; + axiom_text_t *data_text = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + axiom_data_handler_t *data_handler = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node); + + file_om_ele = + axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node); + axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node); + + image_om_ele = + axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node); + + /* This is when we directly give file name */ + + data_handler = axiom_data_handler_create(env, image_name, "image/jpeg"); + + /* Uncomment following to set a callback instead of a file */ + + /*data_handler = axiom_data_handler_create(env, NULL, "image/jpeg"); + axiom_data_handler_set_data_handler_type(data_handler, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK); + axiom_data_handler_set_user_param(data_handler, env, (void *)image_name);*/ + + data_text = + axiom_text_create_with_data_handler(env, image_om_node, data_handler, + &data_om_node); + + axiom_text_set_optimize(data_text, env, optimized); + /*axiom_text_set_is_swa(data_text, env, AXIS2_TRUE);*/ + om_str = axiom_node_to_string(mtom_om_node, env); + if (om_str) + { + printf("%s", om_str); + AXIS2_FREE(env->allocator, om_str); + } + return mtom_om_node; +} + + +int +process_response_node( + const axutil_env_t * env, + axiom_node_t *node, + const axis2_char_t * to_save_name) +{ + axiom_node_t *res_om_node = NULL; + axiom_element_t *res_om_ele = NULL; + res_om_node = axiom_node_get_first_child(node, env); + + if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT) + {/** received mtom atttachment */ + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env); + data_handler = axiom_text_get_data_handler(axiom_text, env); + + /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/ + if(axiom_data_handler_get_cached(data_handler, env)) + { + printf("Attachment is cached.\n"); + } + else + { + axiom_data_handler_set_file_name(data_handler, env, "test"); + axiom_data_handler_write_to(data_handler, env); + } + }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){ + res_om_ele = axiom_node_get_data_element(res_om_node, env); + printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node)); + } + + return 0; +} + + diff --git a/samples/client/mtom/resources/Makefile.am b/samples/client/mtom/resources/Makefile.am new file mode 100644 index 0000000..ee7e84b --- /dev/null +++ b/samples/client/mtom/resources/Makefile.am @@ -0,0 +1,3 @@ +samplesdir=$(prefix)/samples/bin/resources +samples_DATA=axis2.jpg +EXTRA_DIST=axis2.jpg diff --git a/samples/client/mtom/resources/axis2.jpg b/samples/client/mtom/resources/axis2.jpg new file mode 100644 index 0000000..73371d8 Binary files /dev/null and b/samples/client/mtom/resources/axis2.jpg differ diff --git a/samples/client/mtom_callback/Makefile.am b/samples/client/mtom_callback/Makefile.am new file mode 100644 index 0000000..10b1001 --- /dev/null +++ b/samples/client/mtom_callback/Makefile.am @@ -0,0 +1,19 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = mtom_callback + +mtom_callback_SOURCES = mtom_callback_client.c + +mtom_callback_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=mtom_callback.mk diff --git a/samples/client/mtom_callback/mtom_callback.mk b/samples/client/mtom_callback/mtom_callback.mk new file mode 100644 index 0000000..ff59030 --- /dev/null +++ b/samples/client/mtom_callback/mtom_callback.mk @@ -0,0 +1,4 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:mtom_callback.exe + diff --git a/samples/client/mtom_callback/mtom_callback_client.c b/samples/client/mtom_callback/mtom_callback_client.c new file mode 100644 index 0000000..464d997 --- /dev/null +++ b/samples/client/mtom_callback/mtom_callback_client.c @@ -0,0 +1,261 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * image_name); + +int +process_response_node( + const axutil_env_t * env, + axiom_node_t *node); + + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + const axis2_char_t *image_name = "resources/axis2.jpg"; + + /* Set up the environment */ + env = axutil_env_create_all("mtom_callback.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of mtom service */ + address = "http://localhost:9090/axis2/services/mtom_callback"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf + ("Usage : %s [endpoint_url] [image_name] \n", + argv[0]); + printf("use -h for help\n"); + return 0; + } + if (argc > 2) + image_name = argv[2]; + + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/mtomCallbackSample"); + + axis2_options_set_soap_version(options, env, AXIOM_SOAP11); + + axis2_options_set_enable_mtom(options, env, AXIS2_TRUE); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = + build_om_programatically(env, image_name); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE) + { + printf("\nRecieved Fault : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + else + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + printf("\nmtom client invoke SUCCESSFUL!\n"); + process_response_node(env, ret_node); + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("\nmtom client invoke FAILED!\n"); + printf("\nSending callback may not be set. Check the log for more details.\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; + +} + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env, + const axis2_char_t * attachment_name) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *attachment_om_node = NULL; + axiom_element_t *attachment_om_ele = NULL; + axiom_node_t *data_om_node = NULL; + axiom_text_t *data_text = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + axiom_data_handler_t *data_handler = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node); + + attachment_om_ele = + axiom_element_create(env, mtom_om_node, "attachment", ns1, &attachment_om_node); + + /* The attachment is loaded using the callback. The callback should be + * specified in the axis2.xml */ + + data_handler = axiom_data_handler_create(env, NULL, "image/jpeg"); + axiom_data_handler_set_data_handler_type(data_handler, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK); + axiom_data_handler_set_user_param(data_handler, env, (void *)attachment_name); + + data_text = + axiom_text_create_with_data_handler(env, attachment_om_node, data_handler, + &data_om_node); + + axiom_text_set_optimize(data_text, env, AXIS2_TRUE); + om_str = axiom_node_to_string(mtom_om_node, env); + if (om_str) + { + printf("%s", om_str); + AXIS2_FREE(env->allocator, om_str); + } + return mtom_om_node; +} + + +int +process_response_node( + const axutil_env_t * env, + axiom_node_t *node) +{ + axiom_node_t *res_om_node = NULL; + res_om_node = axiom_node_get_first_child(node, env); + + if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT) + {/** received mtom atttachment */ + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env); + data_handler = axiom_text_get_data_handler(axiom_text, env); + + if(axiom_data_handler_get_cached(data_handler, env)) + { + axis2_char_t *mime_id = NULL; + + printf("Attachment is cached.\n"); + + mime_id = axiom_data_handler_get_mime_id(data_handler, env); + if(mime_id) + { + /* The client implementer should know what to do with + * the attachment in the response. Becasue the attachment + * was stored using the callback given by the client */ + + /*axis2_char_t command[1000]; + + sprintf(command, "rm -f /opt/tmp/%s", mime_id); + system(command);*/ + } + } + else + { + axiom_data_handler_set_file_name(data_handler, env, "test"); + axiom_data_handler_write_to(data_handler, env); + } + } + else + { + printf("No attachemnt in the response\n"); + } + + return 0; +} + + diff --git a/samples/client/notify/Makefile.am b/samples/client/notify/Makefile.am new file mode 100644 index 0000000..c89bd4c --- /dev/null +++ b/samples/client/notify/Makefile.am @@ -0,0 +1,18 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = notify +notify_SOURCES = notify_client.c + +notify_LDADD = \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=notify.mk diff --git a/samples/client/notify/notify.mk b/samples/client/notify/notify.mk new file mode 100644 index 0000000..f1759e2 --- /dev/null +++ b/samples/client/notify/notify.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:notify.exe + + + + + diff --git a/samples/client/notify/notify_client.c b/samples/client/notify/notify_client.c new file mode 100644 index 0000000..15629b0 --- /dev/null +++ b/samples/client/notify/notify_client.c @@ -0,0 +1,152 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env); + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axis2_status_t status = AXIS2_FAILURE; + + /* Set up the environment */ + env = axutil_env_create_all("notify.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/notify"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, "http://example.org/action/notify"); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_programatically(env); + + /* Send request */ + status = axis2_svc_client_send_robust(svc_client, env, payload); + + if (status == AXIS2_SUCCESS) + { + printf("\nnotify client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("notify client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env) +{ + axiom_node_t *notify_om_node = NULL; + axiom_element_t *notify_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *buffer = NULL; + + ns1 = axiom_namespace_create(env, "http://example.org/notify", "m"); + notify_om_ele = + axiom_element_create(env, NULL, "notify", ns1, ¬ify_om_node); + axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node); + + buffer = axiom_node_to_string(notify_om_node, env); + if (buffer) + { + printf("\nSending OM node in XML : %s \n", buffer); + AXIS2_FREE(env->allocator, buffer); + } + + return notify_om_node; +} diff --git a/samples/client/version/Makefile.am b/samples/client/version/Makefile.am new file mode 100644 index 0000000..9e66c83 --- /dev/null +++ b/samples/client/version/Makefile.am @@ -0,0 +1,19 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = version +noinst_HEADERS = axis2_version_stub.h +version_SOURCES = axis2_version_stub.c \ + version_client.c + +version_LDADD = \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + diff --git a/samples/client/version/axis2_version_stub.c b/samples/client/version/axis2_version_stub.c new file mode 100644 index 0000000..168e1b0 --- /dev/null +++ b/samples/client/version/axis2_version_stub.c @@ -0,0 +1,114 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_version_stub.h" + +axis2_stub_t * +axis2_version_stub_create_with_endpoint_ref_and_client_home( + const axutil_env_t * env, + axis2_endpoint_ref_t * endpoint_ref, + axis2_char_t * client_home) +{ + axis2_stub_t *stub = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + stub = (axis2_stub_t *) + axis2_stub_create_with_endpoint_ref_and_client_home(env, endpoint_ref, + client_home); + if (!stub) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + axis2_populate_axis_service(stub, env); + return stub; +} + +void +axis2_populate_axis_service( + axis2_stub_t * stub, + const axutil_env_t * env) +{ + axis2_svc_client_t *svc_client = NULL; + axutil_qname_t *op_qname = NULL; + axis2_svc_t *svc = NULL; + axis2_op_t *op = NULL; + + /*Modifying the Service */ + svc_client = axis2_stub_get_svc_client(stub, env); + svc = axis2_svc_client_get_svc(svc_client, env); + + /*creating the operations */ + + op_qname = axutil_qname_create(env, "GetVersion", "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + axis2_op_set_msg_exchange_pattern(op, env, AXIS2_MEP_URI_OUT_IN); + axis2_svc_add_op(svc, env, op); + axutil_qname_free(op_qname, env); + +} + +axis2_stub_t * +axis2_version_stub_create_with_endpoint_uri_and_client_home( + const axutil_env_t * env, + const axis2_char_t * endpoint_uri, + const axis2_char_t * client_home) +{ + axis2_stub_t *stub = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + stub = (axis2_stub_t *) + axis2_stub_create_with_endpoint_uri_and_client_home(env, endpoint_uri, + client_home); + if (!stub) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + axis2_populate_axis_service(stub, env); + + return stub; +} + +/***************************Function implementation****************************/ + +axiom_node_t * +axis2_version_stub_get_version( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axutil_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = axis2_stub_get_svc_client(stub, env); + op_qname = axutil_qname_create(env, "GetVersion", "", NULL); + ret_node = + axis2_svc_client_send_receive_with_op_qname(svc_client, env, op_qname, + node); + axutil_qname_free(op_qname, env); + + return ret_node; +} + diff --git a/samples/client/version/axis2_version_stub.h b/samples/client/version/axis2_version_stub.h new file mode 100644 index 0000000..9ebdfa5 --- /dev/null +++ b/samples/client/version/axis2_version_stub.h @@ -0,0 +1,71 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIS2_VERSION_STUB_H +#define AXIS2_VERSION_STUB_H + +/** + * @file axis2_version_stub.h + * @brief axis2 version stub interface + */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + axiom_node_t *axis2_version_stub_get_version( + axis2_stub_t * stub, + const axutil_env_t * env, + axiom_node_t * node); + + /** + * populate services + */ + void axis2_populate_axis_service( + axis2_stub_t * stub, + const axutil_env_t * env); + + /** + * Creates axis2_stub struct + * @param endpoint reference + * @return pointer to newly created axis2_stub struct + */ + axis2_stub_t *axis2_version_stub_create_with_endpoint_ref_and_client_home( + const axutil_env_t * env, + axis2_endpoint_ref_t * endpoint_ref, + axis2_char_t * client_home); + + /** + * Creates axis2_stub struct + * @param endpoint uri + * @return pointer to newly created axis2_stub struct + */ + axis2_stub_t *axis2_version_stub_create_with_endpoint_uri_and_client_home( + const axutil_env_t * env, + const axis2_char_t * endpoint_uri, + const axis2_char_t * client_home); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_VERSION_STUB_H */ diff --git a/samples/client/version/services.xml b/samples/client/version/services.xml new file mode 100644 index 0000000..88fa9a1 --- /dev/null +++ b/samples/client/version/services.xml @@ -0,0 +1,9 @@ + + version + + This is a testing service, named 'version' to test multiple operations in the same service + + + + + diff --git a/samples/client/version/test.xml b/samples/client/version/test.xml new file mode 100644 index 0000000..ca6650c --- /dev/null +++ b/samples/client/version/test.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/samples/client/version/version_client.c b/samples/client/version/version_client.c new file mode 100644 index 0000000..b72d242 --- /dev/null +++ b/samples/client/version/version_client.c @@ -0,0 +1,185 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_version_stub.h" +#include +#include +#include +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env); + +int +main( + int argc, + char **argv) +{ + axis2_stub_t *stub = NULL; + axiom_node_t *node = NULL; + axis2_status_t status = AXIS2_FAILURE; + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + const axis2_char_t *client_home = NULL; + axiom_node_t *ret_node = NULL; + + const axis2_char_t *operation = "get_version"; + const axis2_char_t *param1 = "40"; + const axis2_char_t *param2 = "8"; + + env = axutil_env_create_all("version_blocking.log", AXIS2_LOG_LEVEL_TRACE); + + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + address = "http://localhost:9090/axis2/services/version"; + if (argc > 1) + operation = argv[1]; + if (axutil_strcmp(operation, "-h") == 0) + { + printf("Usage : %s [operation] [param1] [param2] [endpoint_url]\n", + argv[0]); + printf("use -h for help\n"); + printf("default operation get_version\n"); + printf("default param1 %s\n", param1); + printf("default param2 %s\n", param2); + printf("default endpoint_url %s\n", address); + printf + ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n"); + return 0; + } + if (argc > 2) + param1 = argv[2]; + if (argc > 3) + param2 = argv[3]; + if (argc > 4) + address = argv[4]; + + printf("Using endpoint : %s\n", address); + printf("\nInvoking operation %s\n", operation); + + node = build_om_programatically(env); + stub = + axis2_version_stub_create_with_endpoint_uri_and_client_home(env, address, + client_home); + + /* create node and invoke version */ + if (stub) + { + ret_node = axis2_version_stub_get_version(stub, env, node); + } + + if (ret_node) + { + if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT) + { + axis2_char_t *result = NULL; + axiom_element_t *result_ele = + (axiom_element_t *) axiom_node_get_data_element(ret_node, env); + + result = axiom_element_get_text(result_ele, env, ret_node); + printf("\nResult = %s\n", result); + } + else + { + axiom_xml_writer_t *writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(env, writer); + + axiom_node_serialize(ret_node, env, om_output); + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, env); + printf("\nReceived invalid OM as result : %s\n", buffer); + if (buffer) + { + AXIS2_FREE(env->allocator, buffer); + buffer = NULL; + } + if (om_output) + { + axiom_output_free(om_output, env); + om_output = NULL; + } + axiom_xml_writer_free(writer, env); + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("version stub invoke FAILED!\n"); + } + + if (stub) + { + axis2_stub_free(stub, env); + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return status; +} + +axiom_node_t * +build_om_programatically( + const axutil_env_t * env) +{ + axiom_node_t *version_om_node = NULL; + axiom_element_t *version_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + + ns1 = + axiom_namespace_create(env, "urn:aewebservices71", + "ns1"); + + version_om_ele = + axiom_element_create(env, NULL, "GetVersion", ns1, &version_om_node); + + + xml_writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(env, xml_writer); + + axiom_node_serialize(version_om_node, env, om_output); + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env); + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n", + buffer); + if (om_output) + { + axiom_output_free(om_output, env); + om_output = NULL; + } + + return version_om_node; +} diff --git a/samples/client/yahoo/Makefile.am b/samples/client/yahoo/Makefile.am new file mode 100644 index 0000000..3d8c3c8 --- /dev/null +++ b/samples/client/yahoo/Makefile.am @@ -0,0 +1,17 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = yahoosearch +yahoosearch_SOURCES = yahoo_client.c + +yahoosearch_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=yahoo.mk diff --git a/samples/client/yahoo/yahoo.mk b/samples/client/yahoo/yahoo.mk new file mode 100644 index 0000000..815ad00 --- /dev/null +++ b/samples/client/yahoo/yahoo.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:yahoo.exe + + + + + diff --git a/samples/client/yahoo/yahoo_client.c b/samples/client/yahoo/yahoo_client.c new file mode 100644 index 0000000..01fd97b --- /dev/null +++ b/samples/client/yahoo/yahoo_client.c @@ -0,0 +1,207 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +axiom_node_t *build_yahoo_rest_payload( + const axutil_env_t * env, + axis2_char_t * string); + +void format_output( + const axutil_env_t * env, + axiom_node_t * ret_node); + +void format_output_one( + const axutil_env_t * env, + axiom_node_t * child_node); + +int print_help( + ); + +int +main( + int argc, + char *argv[]) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + axis2_char_t *search_string = NULL; + + if (argc > 1) + { + + if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) + { + print_help(); + } + else + search_string = argv[1]; + } + + env = axutil_env_create_all("yahoo_rest_search.log", AXIS2_LOG_LEVEL_TRACE); + address = "http://search.yahooapis.com/WebSearchService/V1/webSearch"; + + printf("using endpoint %s \n", address); + + endpoint_ref = axis2_endpoint_ref_create(env, address); + + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + + axis2_options_set_enable_rest(options, env, AXIS2_TRUE); + axis2_options_set_http_method(options, env, AXIS2_HTTP_GET); + + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_yahoo_rest_payload(env, search_string); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + format_output(env, ret_node); + printf("\nYahoo REST client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("Yahoo REST client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +axiom_node_t * +build_yahoo_rest_payload( + const axutil_env_t * env, + axis2_char_t * string) +{ + axiom_node_t *root_node; + axiom_node_t *appid_node; + axiom_node_t *query_node; + axiom_element_t *appid_element; + axiom_element_t *query_element; + axiom_element_t *root_element; + + root_element = + axiom_element_create(env, NULL, "yahoo_rest_search", NULL, &root_node); + appid_element = + axiom_element_create(env, root_node, "appid", NULL, &appid_node); + axiom_element_set_text(appid_element, env, "YahooDemo", appid_node); + query_element = + axiom_element_create(env, root_node, "query", NULL, &query_node); + + if (string) + { + axiom_element_set_text(query_element, env, string, query_node); + } + else + { + axiom_element_set_text(query_element, env, "finance", query_node); + } + + return root_node; +} + +void +format_output( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *child_node; + child_node = axiom_node_get_first_child(node, env); + while (axiom_node_is_complete(node, env) && child_node) + { + printf("\n\n"); + format_output_one(env, child_node); + child_node = axiom_node_get_next_sibling(child_node, env); + } + +} + +void +format_output_one( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *child_node; + child_node = axiom_node_get_first_child(node, env); + while (axiom_node_is_complete(node, env) && child_node) + { + axis2_char_t *om_str = axiom_node_to_string(child_node, env); + if (om_str) + { + printf("\t%s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + child_node = axiom_node_get_next_sibling(child_node, env); + } +} + +int +print_help( + ) +{ + printf("./yahoosearch string_to_search \n"); + exit(0); + return 0; +} diff --git a/samples/codegen/client/calc_xml_inout/Makefile.am b/samples/codegen/client/calc_xml_inout/Makefile.am new file mode 100644 index 0000000..aa3981c --- /dev/null +++ b/samples/codegen/client/calc_xml_inout/Makefile.am @@ -0,0 +1,24 @@ +prgbindir=$(prefix)/bin/samples +prgbin_PROGRAMS = Calculator +samplesdir=$(prefix)/samples/client/Calculator + +Calculator_SOURCES = \ + test_Calcultor.c \ + axis2_Calculator_stub.c + + +Calculator_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/client/calc_xml_inout/readme b/samples/codegen/client/calc_xml_inout/readme new file mode 100644 index 0000000..905d49a --- /dev/null +++ b/samples/codegen/client/calc_xml_inout/readme @@ -0,0 +1,12 @@ +This sample demostrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +sample source test_calcultor.c +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/Calculator.wsdl + +Command to execute the code generation: +WSDL2C.sh -uri -l c -d none +WSDL2C.bat -uri -l c -d none + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt +on how to use the script diff --git a/samples/codegen/client/calc_xml_inout/test_calculator.c b/samples/codegen/client/calc_xml_inout/test_calculator.c new file mode 100644 index 0000000..572e809 --- /dev/null +++ b/samples/codegen/client/calc_xml_inout/test_calculator.c @@ -0,0 +1,125 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_Calculator.h" + +axiom_node_t *generate_request_xml( + const axutil_env_t * env); +void handle_respone_xml( + const axutil_env_t * env, + axiom_node_t * res); + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *operation = NULL; + axis2_char_t *client_home = NULL; + + axis2_char_t *endpoint_uri = NULL; + + axis2_stub_t *stub = NULL; + + axiom_node_t *req = NULL; + axiom_node_t *res = NULL; + + endpoint_uri = "http://localhost:9090/axis2/services/Calculator"; + + env = + axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = axis2_stub_create_Calculator(env, client_home, endpoint_uri); + + req = generate_request_xml(env); + + /* invoke the web service method */ + res = axis2_stub_op_Calculator_add(stub, env, req); + + handle_respone_xml(env, res); + + return 0; +} + +axiom_node_t * +generate_request_xml( + const axutil_env_t * env) +{ + axiom_node_t *op_node = NULL; + axiom_element_t *op_ele = NULL; + axiom_node_t *value_node = NULL; + axiom_element_t *value_ele = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + int value1 = 13; + int value2 = 7; + char value_str[64]; + + ns1 = + axiom_namespace_create(env, "http://localhost/axis/Calculator", "ns1"); + op_ele = axiom_element_create(env, NULL, "add", ns1, &op_node); + + value_ele = axiom_element_create(env, op_node, "in1", NULL, &value_node); + sprintf(value_str, "%d", value1); + axiom_element_set_text(value_ele, env, value_str, value_node); + + value_ele = axiom_element_create(env, op_node, "in2", NULL, &value_node); + sprintf(value_str, "%d", value1); + axiom_element_set_text(value_ele, env, value_str, value_node); + + printf("requesting %d + %d \n", value1, value2); + om_str = axiom_node_to_string(op_node, env); + if (om_str) + printf("\nSending OM : %s\n", om_str); + + return op_node; + +} + +void +handle_respone_xml( + const axutil_env_t * env, + axiom_node_t * res) +{ + axiom_node_t *node = NULL; + axiom_element_t *ele = NULL; + axis2_char_t *text = NULL; + + if (!res) + { + printf("response null\n"); + return; + } + node = axiom_node_get_first_child(res, env); + if (node) + { + ele = axiom_node_get_data_element(node, env); + text = axiom_element_get_text(ele, env, node); + + printf("answer = %s\n", text); + } + +} diff --git a/samples/codegen/client/calculator/Makefile.am b/samples/codegen/client/calculator/Makefile.am new file mode 100644 index 0000000..9e75ed0 --- /dev/null +++ b/samples/codegen/client/calculator/Makefile.am @@ -0,0 +1,26 @@ +prgbindir=$(prefix)/bin/samples +prgbin_PROGRAMS = Calculator +samplesdir=$(prefix)/samples/client/Calculator + +Calculator_SOURCES = \ +axis2_add.c axis2_Calculator_stub.c axis2_divResponse.c axis2_mulResponse.c axis2_subResponse.c \ +axis2_addRequest.c axis2_div.c axis2_mul.c axis2_sub.c test_Calcultor.c \ +axis2_addResponse20.c axis2_divRequest.c axis2_mulRequest.c axis2_subRequest.c \ +axis2_addResponse.c axis2_divResponse16.c axis2_mulResponse14.c axis2_subResponse12.c + + +Calculator_LDADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/client/calculator/readme b/samples/codegen/client/calculator/readme new file mode 100644 index 0000000..2a7a351 --- /dev/null +++ b/samples/codegen/client/calculator/readme @@ -0,0 +1,15 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +sample source test_calcultor.c +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/Calculator.wsdl + + +Command to execute the code generation: + +WSDL2C.sh -uri Calculator.wsdl -u -d adb +WSDL2C.bat -uri Calculator.wsdl -u -d adb + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt +on how to use the script + diff --git a/samples/codegen/client/calculator/test_calculator.c b/samples/codegen/client/calculator/test_calculator.c new file mode 100644 index 0000000..2f4d2eb --- /dev/null +++ b/samples/codegen/client/calculator/test_calculator.c @@ -0,0 +1,77 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_Calculator.h" + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *operation = NULL; + axis2_char_t *client_home = NULL; + + axis2_char_t *endpoint_uri = NULL; + + axis2_stub_t *stub = NULL; + + /* variables use databinding */ + adb_addResponse_t *add_res = NULL; + adb_add_t *add_req = NULL; + + int ret_val = 0; + + int val1 = 8; + int val2 = 13; + + endpoint_uri = "http://localhost:9090/axis2/services/calculator"; + + env = + axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = axis2_stub_create_Calculator(env, client_home, endpoint_uri); + + /* create the struct */ + add_req = adb_add_create(env); + adb_add_set_in0(add_req, env, val1); + adb_add_set_in1(add_req, env, val2); + + + /* invoke the web service method */ + add_res = axis2_stub_op_Calculator_add(stub, env, add_req); + + if (!add_res) + { + printf("Error: response NULL\n"); + return -1; + } + + /* return the output params using databinding */ + ret_val = adb_addResponse_get_addReturn(add_res, env); + + printf("finally: add (%d %d ) = %d\n", val1, val2, ret_val); + + return 0; +} diff --git a/samples/codegen/client/interop_doc1/Makefile.am b/samples/codegen/client/interop_doc1/Makefile.am new file mode 100644 index 0000000..ff7ecb8 --- /dev/null +++ b/samples/codegen/client/interop_doc1/Makefile.am @@ -0,0 +1,56 @@ +prgbindir=$(prefix)/bin/samples +samplesdir=$(prefix)/samples/client/InteropTestPortTypeDocService +prgbin_PROGRAMS = test_echo_date test_echo_struct_array +test_echo_date_SOURCES = \ +axis2_echoBase64.c axis2_echoFloat.c axis2_echoString.c \ +axis2_echoBase64Response.c axis2_echoFloatResponse.c axis2_echoStringResponse.c \ +axis2_echoBoolean.c axis2_echoHexBinary.c axis2_echoStructArray.c \ +axis2_echoBooleanResponse.c axis2_echoHexBinaryResponse.c axis2_echoStructArrayResponse.c \ +axis2_echoDate.c axis2_echoIntegerArray.c axis2_echoStruct.c \ +axis2_echoDateResponse.c axis2_echoIntegerArrayResponse.c axis2_echoStructResponse.c \ +axis2_echoDecimal.c axis2_echoInteger.c axis2_echoVoid.c \ +axis2_echoDecimalResponse.c axis2_echoIntegerResponse.c axis2_echoVoidResponse.c \ +axis2_echoFloatArray.c axis2_echoStringArray.c axis2_InteropTestPortTypeDocService_stub.c \ +axis2_echoFloatArrayResponse.c axis2_echoStringArrayResponse.c axis2_SOAPStruct.c \ +test_echo_date.c + +test_echo_date_LDADD = \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +test_echo_struct_array_SOURCES = \ +axis2_echoBase64.c axis2_echoFloat.c axis2_echoString.c \ +axis2_echoBase64Response.c axis2_echoFloatResponse.c axis2_echoStringResponse.c \ +axis2_echoBoolean.c axis2_echoHexBinary.c axis2_echoStructArray.c \ +axis2_echoBooleanResponse.c axis2_echoHexBinaryResponse.c axis2_echoStructArrayResponse.c \ +axis2_echoDate.c axis2_echoIntegerArray.c axis2_echoStruct.c \ +axis2_echoDateResponse.c axis2_echoIntegerArrayResponse.c axis2_echoStructResponse.c \ +axis2_echoDecimal.c axis2_echoInteger.c axis2_echoVoid.c \ +axis2_echoDecimalResponse.c axis2_echoIntegerResponse.c axis2_echoVoidResponse.c \ +axis2_echoFloatArray.c axis2_echoStringArray.c axis2_InteropTestPortTypeDocService_stub.c \ +axis2_echoFloatArrayResponse.c axis2_echoStringArrayResponse.c axis2_SOAPStruct.c \ +test_echo_struct_array.c + +test_echo_struct_array_LDADD = \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/client/interop_doc1/readme b/samples/codegen/client/interop_doc1/readme new file mode 100644 index 0000000..dc4ed1f --- /dev/null +++ b/samples/codegen/client/interop_doc1/readme @@ -0,0 +1,13 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +sample sources test_echo_date.c test_echo_struct_array.c +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/InteropTestRound1Doc.wsdl + +Command to execute the code generation: +WSDL2C.sh -uri InteropTestRound1Doc.wsdl -u -d adb +WSDL2C.bat -uri InteropTestRound1Doc.wsdl -u -d adb + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt +on how to use the script + diff --git a/samples/codegen/client/interop_doc1/test_echo_date.c b/samples/codegen/client/interop_doc1/test_echo_date.c new file mode 100644 index 0000000..b66c33d --- /dev/null +++ b/samples/codegen/client/interop_doc1/test_echo_date.c @@ -0,0 +1,77 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_InteropTestPortTypeDocService.h" + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *client_home = NULL; + + axis2_char_t *endpoint_uri = NULL; + + axis2_stub_t *stub = NULL; + + /* variables use databinding */ + adb_echoDate_t *echo_in = NULL; + adb_echoDateResponse_t *echo_out = NULL; + + axutil_date_time_t *echo_date = NULL; + axutil_date_time_t *return_echo_date = NULL; + + axis2_char_t *send_date_str = NULL; + axis2_char_t *return_date_str = NULL; + + endpoint_uri = "http://localhost:9090/axis2/services/interop_doc1"; + + env = axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = axis2_stub_create_InteropTestPortTypeDocService(env, + client_home, + endpoint_uri); + + /* create the struct */ + echo_date = axutil_date_time_create(env); /* default to current date */ + send_date_str = axutil_date_time_serialize_date_time(echo_date, env); + printf("sending date %s\n", send_date_str); + + /* create the input params using databinding */ + echo_in = adb_echoDate_create(env); + adb_echoDate_set_arg_0_10(echo_in, env, echo_date); + + /* invoke the web service method */ + echo_out = axis2_stub_op_InteropTestPortTypeDocService_echoDate(stub, env, echo_in); + + /* return the output params using databinding */ + return_echo_date = adb_echoDateResponse_get_echoDateReturn(echo_out, env); + + return_date_str = + axutil_date_time_serialize_date_time(return_echo_date, env); + printf("returned date %s\n", return_date_str); + + return 0; +} diff --git a/samples/codegen/client/interop_doc1/test_echo_struct_array.c b/samples/codegen/client/interop_doc1/test_echo_struct_array.c new file mode 100644 index 0000000..19a3a9a --- /dev/null +++ b/samples/codegen/client/interop_doc1/test_echo_struct_array.c @@ -0,0 +1,93 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_InteropTestPortTypeDocService.h" + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *client_home = NULL; + axis2_char_t *endpoint_uri = NULL; + axis2_stub_t *stub = NULL; + + /* variables use databinding */ + adb_echoStructArray_t *echo_in = NULL; + adb_echoStructArrayResponse_t *echo_out = NULL; + + adb_SOAPStruct_t *echo_struct = NULL; + int arr_size = 0; + int ret_arr_size = 0; + + int i = 0; /* for for loop */ + + endpoint_uri = "http://localhost:9090/axis2/services/interop_doc1"; + + env = axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = axis2_stub_create_InteropTestPortTypeDocService(env, + client_home, + endpoint_uri); + + /* create the struct */ + echo_in = adb_echoStructArray_create(env); + + /* create the struct array */ + echo_struct = adb_SOAPStruct_create(env); + adb_SOAPStruct_set_varString(echo_struct, env, "sturct0"); + adb_SOAPStruct_set_varInt(echo_struct, env, 0); + adb_SOAPStruct_set_varFloat(echo_struct, env, 0); + + adb_echoStructArray_add_arg_0_7(echo_in, env, echo_struct); + + echo_struct = adb_SOAPStruct_create(env); + adb_SOAPStruct_set_varString(echo_struct, env, "sturct1"); + adb_SOAPStruct_set_varInt(echo_struct, env, 10); + adb_SOAPStruct_set_varFloat(echo_struct, env, 100); + + adb_echoStructArray_add_arg_0_7(echo_in, env, echo_struct); + + echo_struct = adb_SOAPStruct_create(env); + adb_SOAPStruct_set_varString(echo_struct, env, "sturct2"); + adb_SOAPStruct_set_varInt(echo_struct, env, 20); + adb_SOAPStruct_set_varFloat(echo_struct, env, 200); + + adb_echoStructArray_add_arg_0_7(echo_in, env, echo_struct); + + /* invoke the web service method */ + echo_out = axis2_stub_op_InteropTestPortTypeDocService_echoStruct(stub, env, echo_in); + + ret_arr_size = adb_echoStructArrayResponse_sizeof_echoStructArrayReturn(echo_out, env); + for (i = 0; i < ret_arr_size; i++) + { + echo_struct = adb_echoStructArrayResponse_get_echoStructArrayReturn(echo_out, env); + printf("recieved turn %d \n string %s\n int %d\n float %f\n\n", i, + adb_SOAPStruct_get_varString(echo_struct, env), + adb_SOAPStruct_get_varInt(echo_struct, env), + adb_SOAPStruct_get_varFloat(echo_struct, env)); + } + return 0; +} diff --git a/samples/codegen/client/interop_doc2/Makefile.am b/samples/codegen/client/interop_doc2/Makefile.am new file mode 100644 index 0000000..1208385 --- /dev/null +++ b/samples/codegen/client/interop_doc2/Makefile.am @@ -0,0 +1,42 @@ +prgbindir = $(prefix)/bin/samples +prgbin_PROGRAMS = test_echo_string test_echo_struct test_echo_string_array +samplesdir = $(prefix)/samples/client/WSDLInteropTestDocLitService + +test_echo_string_SOURCES = \ + axis2_ArrayOfstring_literal.c axis2_echoStringArray.c axis2_echoStringArrayResponse.c \ + axis2_echoString.c axis2_echoStringResponse.c axis2_echoStruct.c axis2_echoStructResponse.c \ + axis2_echoVoid.c axis2_echoVoidResponse.c axis2_SOAPStruct.c axis2_WSDLInteropTestDocLitService_stub.c \ + test_echo_string.c +test_echo_string_LDADD = \ + $(LDFLAGS) -L$(AXIS2C_HOME)/lib -laxutil -laxis2_axiom \ + -laxis2_wsdl -laxis2_engine -laxis2_parser -lpthread -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +test_echo_struct_SOURCES = \ + axis2_ArrayOfstring_literal.c axis2_echoStringArray.c \ + axis2_echoStringArrayResponse.c axis2_echoString.c \ + axis2_echoStringResponse.c axis2_echoStruct.c axis2_echoStructResponse.c \ + axis2_echoVoid.c axis2_echoVoidResponse.c axis2_SOAPStruct.c \ + axis2_WSDLInteropTestDocLitService_stub.c test_echo_struct.c +test_echo_struct_LDADD = \ + $(LDFLAGS) -L$(AXIS2C_HOME)/lib -laxutil -laxis2_axiom \ + -laxis2_wsdl -laxis2_engine -laxis2_parser -lpthread -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +test_echo_string_array_SOURCES = \ + axis2_ArrayOfstring_literal.c axis2_echoStringArray.c \ + axis2_echoStringArrayResponse.c axis2_echoString.c \ + axis2_echoStringResponse.c axis2_echoStruct.c axis2_echoStructResponse.c \ + axis2_echoVoid.c axis2_echoVoidResponse.c axis2_SOAPStruct.c \ + axis2_WSDLInteropTestDocLitService_stub.c test_echo_string_array.c +test_echo_string_array_LDADD = \ + $(LDFLAGS) -L$(AXIS2C_HOME)/lib -laxutil -laxis2_axiom \ + -laxis2_wsdl -laxis2_engine -laxis2_parser -lpthread -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/client/interop_doc2/readme b/samples/codegen/client/interop_doc2/readme new file mode 100644 index 0000000..efc2a9f --- /dev/null +++ b/samples/codegen/client/interop_doc2/readme @@ -0,0 +1,13 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +sample sources test_echo_string_array.c test_echo_string.c test_echo_struct.c +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/interoptestdoclitparameters.wsdl + +Command to execute the code generation: + +WSDL2C.sh -uri Calculator.wsdl -u -d adb +WSDL2C.bat -uri Calculator.wsdl -u -d adb + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt +on how to use the script diff --git a/samples/codegen/client/interop_doc2/test_echo_string.c b/samples/codegen/client/interop_doc2/test_echo_string.c new file mode 100644 index 0000000..87ef342 --- /dev/null +++ b/samples/codegen/client/interop_doc2/test_echo_string.c @@ -0,0 +1,70 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_WSDLInteropTestDocLitService.h" + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *client_home = NULL; + + axis2_char_t *endpoint_uri = NULL; + + axis2_stub_t *stub = NULL; + + /* variables use databinding */ + adb_echoString_t *echo_in = NULL; + adb_echoStringResponse_t *echo_out = NULL; + + char *echo_str = "hello"; + char *return_echo_str = NULL; + + endpoint_uri = "http://localhost:9090/axis2/services/interop_doc2"; + + env = + axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = + axis2_stub_create_WSDLInteropTestDocLitService(env, client_home, + endpoint_uri); + + /* create the struct */ + + /* create the input params using databinding */ + echo_in = adb_echoString_create(env); + adb_echoString_set_param0(echo_in, env, echo_str); + + /* invoke the web service method */ + echo_out = axis2_stub_op_WSDLInteropTestDocLitService_echoString(stub, env, echo_in); + + /* return the output params using databinding */ + return_echo_str = adb_echoStructResponse_get_return(echo_out, env); + + printf("returned string %s\n", return_echo_str); + + return 0; +} diff --git a/samples/codegen/client/interop_doc2/test_echo_string_array.c b/samples/codegen/client/interop_doc2/test_echo_string_array.c new file mode 100644 index 0000000..136096c --- /dev/null +++ b/samples/codegen/client/interop_doc2/test_echo_string_array.c @@ -0,0 +1,90 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_WSDLInteropTestDocLitService.h" + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *client_home = NULL; + + axis2_char_t *endpoint_uri = NULL; + + axis2_stub_t *stub = NULL; + + /* variables use databinding */ + adb_echoStringArray_t *echo_in = NULL; + adb_echoStringArrayResponse_t *echo_out = NULL; + adb_ArrayOfstring_literal_t *array_in = NULL; + adb_ArrayOfstring_literal_t *array_out = NULL; + + static char *string_array[] = { "test", "this", "array" }; + int array_length = 3; + + char *string_return = NULL; + int return_array_length = 0; + int i = 0; /* for loops */ + + endpoint_uri = "http://localhost:9090/axis2/services/interop_doc2"; + + env = + axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = + axis2_stub_create_WSDLInteropTestDocLitService(env, client_home, + endpoint_uri); + + /* create the array */ + array_in = adb_ArrayOfstring_literal_create(env); + + for(i = 0; i < array_length; i ++) + { + adb_ArrayOfstring_literal_add_string(array_in, env, + string_array[i]); + } + + /* create the input params using databinding */ + echo_in = adb_echoStringArray_create(env); + adb_echoStringArray_set_param0(echo_in, env, array_in); + + /* invoke the web service method */ + echo_out = axis2_stub_op_WSDLInteropTestDocLitService_echoStringArray(stub, env, echo_in); + + /* return the output params using databinding */ + array_out = adb_echoStringArrayResponse_get_return(echo_out, env); + + + return_array_length = adb_ArrayOfstring_literal_sizeof_string(array_out, env); + + for (i = 0; i < return_array_length; i++) + { + string_return = adb_ArrayOfstring_literal_get_string_at(array_out, env, i); + printf("value%d: %s \n", i, string_return); + } + + return 0; +} diff --git a/samples/codegen/client/interop_doc2/test_echo_struct.c b/samples/codegen/client/interop_doc2/test_echo_struct.c new file mode 100644 index 0000000..06bd7f7 --- /dev/null +++ b/samples/codegen/client/interop_doc2/test_echo_struct.c @@ -0,0 +1,89 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_WSDLInteropTestDocLitService.h" + +int +main( + int argc, + char **argv) +{ + axutil_env_t *env = NULL; + axis2_char_t *client_home = NULL; + + axis2_char_t *endpoint_uri = NULL; + + axis2_stub_t *stub = NULL; + + /* variables use databinding */ + adb_echoStruct_t *echo_in = NULL; + adb_echoStructResponse_t *echo_out = NULL; + adb_SOAPStruct_t *struct_in = NULL; + adb_SOAPStruct_t *struct_out = NULL; + + float float_val = 11; + int int_val = 10; + char *string_val = "hello struct"; + + int ret_int_val = 0; + float ret_float_val = 0; + char *ret_string_val = ""; + + endpoint_uri = "http://localhost:9090/axis2/services/interop_doc2"; + + env = + axutil_env_create_all("codegen_utest_blocking.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + + stub = axis2_stub_create_WSDLInteropTestDocLitService(env, + client_home, + endpoint_uri); + + /* create the struct */ + struct_in = adb_SOAPStruct_create(env); + adb_SOAPStruct_set_varFloat(struct_in, env, float_val); + adb_SOAPStruct_set_varInt(struct_in, env, int_val); + adb_SOAPStruct_set_varString(struct_in, env, string_val); + + /* create the input params using databinding */ + echo_in = adb_echoStruct_create(env); + adb_echoStruct_set_param0(echo_in, env, struct_in); + + /* invoke the web service method */ + echo_out = axis2_stub_op_WSDLInteropTestDocLitService_echoStruct(stub, env, echo_in); + + /* return the output params using databinding */ + struct_out = adb_echoStructResponse_get_return(echo_out, env); + /*struct_out = adb_echostruct_get_param0( ret_val, env ); */ + + ret_float_val = adb_SOAPStruct_get_varFloat(struct_out, env); + ret_int_val = adb_SOAPStruct_get_varInt(struct_out, env); + ret_string_val = adb_SOAPStruct_get_varString(struct_out, env); + + printf("returned values \n"); + printf(" float %f\n", ret_float_val); + printf(" int %d \n", ret_int_val); + printf(" string %s \n", ret_string_val); + + return 0; +} diff --git a/samples/codegen/databinding/Calculator/Calculator.wsdl b/samples/codegen/databinding/Calculator/Calculator.wsdl new file mode 100644 index 0000000..5600279 --- /dev/null +++ b/samples/codegen/databinding/Calculator/Calculator.wsdl @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/codegen/databinding/Calculator/client/CalculatorAdd.c b/samples/codegen/databinding/Calculator/client/CalculatorAdd.c new file mode 100644 index 0000000..edb4b62 --- /dev/null +++ b/samples/codegen/databinding/Calculator/client/CalculatorAdd.c @@ -0,0 +1,38 @@ +#include "axis2_stub_Calculator.h" +int +main( + int argc, + char *argv) +{ + axutil_env_t * env = NULL; + axis2_char_t * operation = NULL; + axis2_char_t * client_home = NULL; + axis2_char_t * endpoint_uri = NULL; + axis2_stub_t * stub = NULL; + adb_addResponse_t * add_res = NULL; + adb_add_t * add_in = NULL; + int res_val = 0; + endpoint_uri = "http://localhost:9090/axis2/services/Calculator"; + env = axutil_env_create_all("alltest.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + stub = axis2_stub_create_Calculator(env, client_home, endpoint_uri); + add_in = adb_add_create(env); + adb_add_set_arg_0_0(add_in, env, 10); + adb_add_set_arg_1_0(add_in, env, 10); + add_res = axis2_stub_op_Calculator_add(stub, env, add_in); + if (!add_res) + + { + printf("Error: response NULL\n"); + return -1; + } + res_val = adb_addResponse_get_addReturn(add_res, env); + printf("ADD Result:%d ", res_val); + return 0; +} + + diff --git a/samples/codegen/databinding/Calculator/server/axis2_skel_Calculator.c b/samples/codegen/databinding/Calculator/server/axis2_skel_Calculator.c new file mode 100644 index 0000000..ab30974 --- /dev/null +++ b/samples/codegen/databinding/Calculator/server/axis2_skel_Calculator.c @@ -0,0 +1,104 @@ + + +/** + * axis2_skel_Calculator.c + * + * This file was auto-generated from WSDL for "Calculator|http://localhost/axis/Calculator" service + * by the Apache Axis2/C version: #axisVersion# #today# + * axis2_skel_Calculator Axis2/C skeleton for the axisService + */ + +#include "axis2_skel_Calculator.h" + + +/** + * auto generated function definition signature + * for "add|" operation. + + * @param add + */ + adb_addResponse_t * axis2_skel_Calculator_add(const axutil_env_t * env, + adb_add_t * add) +{ + adb_addResponse_t * add_res = NULL; + int ret_val = 0; + int val1 = 0; + int val2 = 0; + val1 = adb_add_get_arg_0_0(add, env); + val2 = adb_add_get_arg_1_0(add, env); + ret_val = val1 + val2; + add_res = adb_addResponse_create(env); + adb_addResponse_set_addReturn(add_res, env, ret_val); + return add_res; +} + + + +/** + * auto generated function definition signature + * for "div|" operation. + + * @param div + */ + adb_divResponse_t * axis2_skel_Calculator_div(const axutil_env_t * env, + adb_div_t * div) +{ + adb_divResponse_t * div_res = NULL; + int ret_val = 0; + int val1 = 0; + int val2 = 0; + val1 = adb_div_get_arg_0_3(div, env); + val2 = adb_div_get_arg_1_3(div, env); + ret_val = val1 / val2; + div_res = adb_divResponse_create(env); + adb_divResponse_set_divReturn(div_res, env, ret_val); + return div_res; +} + + + +/** + * auto generated function definition signature + * for "sub|" operation. + + * @param sub + */ + adb_subResponse_t * axis2_skel_Calculator_sub(const axutil_env_t * env, + adb_sub_t * sub) +{ + adb_subResponse_t * sub_res = NULL; + int ret_val = 0; + int val1 = 0; + int val2 = 0; + val1 = adb_sub_get_arg_0_1(sub, env); + val2 = adb_sub_get_arg_1_1(sub, env); + ret_val = val1 - val2; + sub_res = adb_subResponse_create(env); + adb_subResponse_set_subReturn(sub_res, env, ret_val); + return sub_res; +} + + + +/** + * auto generated function definition signature + * for "mul|" operation. + + * @param mul + */ + adb_mulResponse_t * axis2_skel_Calculator_mul(const axutil_env_t * env, + adb_mul_t * mul) +{ + adb_mulResponse_t * mul_res = NULL; + int ret_val = 0; + int val1 = 0; + int val2 = 0; + val1 = adb_mul_get_arg_0_2(mul, env); + val2 = adb_mul_get_arg_1_2(mul, env); + ret_val = val1 * val2; + mul_res = adb_mulResponse_create(env); + adb_mulResponse_set_mulReturn(mul_res, env, ret_val); + return mul_res; +} + + diff --git a/samples/codegen/databinding/READEME.txt b/samples/codegen/databinding/READEME.txt new file mode 100644 index 0000000..7db1592 --- /dev/null +++ b/samples/codegen/databinding/READEME.txt @@ -0,0 +1,66 @@ +Sample: Data Binding +==================== + +Introduction +------------ + +These samples demonstrate the use of code generation using Axis2/Java WSDL2Java +(http://svn.apache.org/repos/asf/webservices/axis2/trunk/java)tool with Axis Data Binding. +You can download the latest update of the tool from +http://people.apache.org/dist/axis2/nightly + +Files +----- + +-StockQuoteService + Client source ./StockQuoteService/stock_quote_client.c + Service Source ./StockQuoteService/axis2_skel_StockQuoteService.c + wsdl ./StockQuoteService/StockQuoteService.wsdl + +-Calculator + Client source ./Calculator/CalculatorAdd.c + Service Source ./Calculator/axis2_skel_Calculator.c + wsdl ./Calculator/Calculator.wsdl + + +Code Generation +--------------- + +Use the shell script or batch file available in the ../../../tools/codegen/javatool directory to generate +code using following options.(Reade the READEME.txt at ../../../tools/codegen/javatool directory to learn how to use scripts) + +Client side stub generation with Axis Data Binding: + Linux: WSDL2C.sh -uri -g -d adb -u -f -o + Win32: WSDL2C.bat -uri -g -d adb -u -f -o + +Server side skeleton generation with Axis Data Binding: + Linux: WSDL2C.sh -uri -sd -ss -d adb -u -f -o + Win32: WSDL2C.bat -uri -sd -ss -d adb -u -f -o + +Description of Options used: + + -o : output file location + -ss : Generate server side code (i.e. skeletons). Default is off + -sd : Generate service descriptor (i.e. services.xml). Default is off. Valid with -ss + -d : valid databinding(s) are adb, xmlbeans and jaxme. Default is adb + -g : Generates all the classes. valid only with the -ss (This will generate client and server codes) + -u : unpacks the databinding classes + -f : Generate the source output folder without the src directory + +Please refer to the http://ws.apache.org/axis2/tools/1_1/CodegenToolReference.html for further details. + +Deploying the Service +--------------------- +You need to generate the required server side code using command described above and replace +the axis2_skel_.c with given implementation. After building the lib.so, +put it inside $AXIS2C_HOME/services// directory. + +You need to then startup the server to deploy the service. + +Running the Client +------------------ +You need to generate the required client side code using command described above and put them inside +where client implementations resides. And then build the client and run it. + + + diff --git a/samples/codegen/databinding/StockQuoteService/StockQuote.xsd b/samples/codegen/databinding/StockQuoteService/StockQuote.xsd new file mode 100644 index 0000000..288a873 --- /dev/null +++ b/samples/codegen/databinding/StockQuoteService/StockQuote.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/codegen/databinding/StockQuoteService/StockQuoteService.wsdl b/samples/codegen/databinding/StockQuoteService/StockQuoteService.wsdl new file mode 100644 index 0000000..7374021 --- /dev/null +++ b/samples/codegen/databinding/StockQuoteService/StockQuoteService.wsdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/codegen/databinding/StockQuoteService/client/stock_quote_client.c b/samples/codegen/databinding/StockQuoteService/client/stock_quote_client.c new file mode 100644 index 0000000..0b921e7 --- /dev/null +++ b/samples/codegen/databinding/StockQuoteService/client/stock_quote_client.c @@ -0,0 +1,121 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version + * 2.0 + * (the "License"); you may not use this file except in compliance + * with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axis2_stub_StockQuoteService.h" +#include +void handle_response( + adb_getStockQuoteResponse_t * res, + axutil_env_t * env); +int +main( + int argc, + char *argv[]) +{ + axutil_env_t * env = NULL; + axis2_char_t * client_home = NULL; + axis2_char_t * endpoint_uri = NULL; + axis2_stub_t * stub = NULL; + axis2_char_t * symbol = NULL; + adb_getStockQuote_t * req = NULL; + adb_getStockQuoteResponse_t * res = NULL; + if (argc > 1) + + { + symbol = argv[1]; + } + + else + + { + printf("\nEnter Symbol Name!"); + return -1; + } + endpoint_uri = "http://localhost:9090/axis2/services/StockQuoteService"; + env = + axutil_env_create_all("codegen_sample_stock_quote.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set up deploy folder. */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../../deploy"; + stub = + axis2_stub_create_StockQuoteService(env, client_home, endpoint_uri); + + /* Create the struct */ + req = adb_getStockQuote_create(env); + adb_getStockQuote_set_symbol(req, env, symbol); + res = axis2_stub_op_StockQuoteService_getStockQuote(stub, env, req); + if (!res) + + { + printf("Error: response NULL!\n"); + return -1; + } + handle_response(res, env); /*Handle Response */ + return 0; +} +void +handle_response( + adb_getStockQuoteResponse_t * res, + axutil_env_t * env) +{ + adb_quote_t * quote = NULL; + adb_changeType_t * change = NULL; + adb_lastTradeType_t * last_trade = NULL; + + /*Attributes of Quote */ + axis2_char_t * symbol_res = NULL; + int volume = 0; + + /*Attributes of Last Trade */ + float price = 0; + long date = 0; + + /*Attributes of Change */ + float dollar = 0; + float precent = 0; + quote = adb_getStockQuoteResponse_get_returnQuote(res, env); + if (!quote) + + { + printf("Error: Quote response NULL!\n"); + return; + } + last_trade = adb_quote_get_lastTrade(quote, env); + change = adb_quote_get_change(quote, env); + symbol_res = adb_quote_get_symbol(quote, env); + volume = adb_quote_get_volume(quote, env); + price = adb_lastTradeType_get_price(last_trade, env); + date = adb_lastTradeType_get_date(last_trade, env); + dollar = adb_changeType_get_dollar(change, env); + precent = adb_changeType_get_percent(change, env); + printf("\nSTOCK QUOTERESPONSE\n"); + printf("\tSYMBOL\t\t: %s\n", symbol_res); + printf("\tVOLUME\t\t: %d\n", volume); + printf("\tPRICE\t\t: %f\n", price); + printf("\tDATE\t\t: %l\n", date); + printf("\tDOLLAR\t\t: %f\n", dollar); + printf("\tPRECENT\t\t: %f\n", precent); +} + + diff --git a/samples/codegen/databinding/StockQuoteService/server/axis2_skel_StockQuoteService.c b/samples/codegen/databinding/StockQuoteService/server/axis2_skel_StockQuoteService.c new file mode 100644 index 0000000..2e33017 --- /dev/null +++ b/samples/codegen/databinding/StockQuoteService/server/axis2_skel_StockQuoteService.c @@ -0,0 +1,75 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * axis2_skel_StockQuoteService.c + * + * This file was auto-generated from WSDL for "StockQuoteService|http://w3.ibm.com/schemas/services/2002/11/15/stockquote/wsdl" service + * by the Apache Axis2/C version: #axisVersion# #today# + * axis2_skel_StockQuoteService Axis2/C skeleton for the axisService + */ + +#include "axis2_skel_StockQuoteService.h" + + +/** + * auto generated function definition signature + * for "getStockQuote|" operation. + + * @param getStockQuote + */ + adb_getStockQuoteResponse_t * +axis2_skel_StockQuoteService_getStockQuote(const axutil_env_t * env, + adb_getStockQuote_t * + getStockQuote) +{ + + /* TODO fill this with the necessary business logic */ + axis2_char_t * symbol_in = NULL; + adb_getStockQuoteResponse_t * response = NULL; + adb_quote_t * res_quote = NULL; + adb_changeType_t * res_change = NULL; + adb_lastTradeType_t * res_last_trade = NULL; + symbol_in = adb_getStockQuote_get_symbol(getStockQuote, env); + if (!symbol_in) + + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf + ("StockQuoteService client request ERROR: input parameter NULL\n"); + return NULL; + } + res_quote = adb_quote_create(env); + adb_quote_set_symbol(res_quote, env, symbol_in); + adb_quote_set_volume(res_quote, env, 1000); + res_change = adb_changeType_create(env); + adb_changeType_set_percent(res_change, env, 10); + adb_changeType_set_dollar(res_change, env, 98); + adb_quote_set_change(res_quote, env, res_change); + res_last_trade = adb_lastTradeType_create(env); + adb_lastTradeType_set_price(res_last_trade, env, 23); + adb_lastTradeType_set_date(res_last_trade, env, 1165997291); + adb_quote_set_lasttrade(res_quote, env, res_last_trade); + response = adb_getStockQuoteResponse_create(env); + adb_getStockQuoteResponse_set_returnQuote(response, env, res_quote); + return response; +} + + diff --git a/samples/codegen/server/calc_xml_inout/Makefile.am b/samples/codegen/server/calc_xml_inout/Makefile.am new file mode 100644 index 0000000..145ef08 --- /dev/null +++ b/samples/codegen/server/calc_xml_inout/Makefile.am @@ -0,0 +1,14 @@ +prglibdir=$(prefix)/services/Calculator +samplesdir=$(prefix)/samples/server/Calculator +prglib_LTLIBRARIES = libCalculator.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml +SUBDIRS = +libCalculator_la_SOURCES = \ + axis2_Calculator.c \ + axis2_Calculator_svc_skeleton.c + +libCalculator_la_LIBADD = +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/server/calc_xml_inout/axis2_skel_Calculator.c b/samples/codegen/server/calc_xml_inout/axis2_skel_Calculator.c new file mode 100644 index 0000000..ceb6bbe --- /dev/null +++ b/samples/codegen/server/calc_xml_inout/axis2_skel_Calculator.c @@ -0,0 +1,135 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * axis2_skel_Calculator.c + * + * This file was auto-generated from WSDL + * by the Apache Axis2/Java version: #axisVersion# #today# + * axis2_skel_Calculator Axis2/C skeleton for the axisService + */ + +#include "axis2_skel_Calculator.h" + +/** + * Auto generated function definition + + * @param param0 + +*/ +axiom_node_t * +axis2_skel_Calculator_add( + const axutil_env_t * env, + axiom_node_t * param0) +{ + /* Todo fill this with the necessary business logic */ + axiom_node_t *req = param0; + axiom_node_t *node = NULL; + axiom_element_t *ele = NULL; + axis2_char_t *text = NULL; + + axiom_node_t *op_node = NULL; + axiom_element_t *op_ele = NULL; + axiom_node_t *value_node = NULL; + axiom_element_t *value_ele = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + char value_str[64]; + + int result = 0; + + int value1, + value2; + if (!req) + { + printf("response null\n"); + return NULL; + } + else + { + node = axiom_node_get_first_child(req, env); + ele = axiom_node_get_data_element(node, env); + text = axiom_element_get_text(ele, env, node); + value1 = atoi(text); + + node = axiom_node_get_next_sibling(node, env); + ele = axiom_node_get_data_element(node, env); + text = axiom_element_get_text(ele, env, node); + value2 = atoi(text); + + } + + result = value1 + value2; + + ns1 = + axiom_namespace_create(env, "http://localhost/axis/Calculator", "ns1"); + op_ele = axiom_element_create(env, NULL, "addResponse", ns1, &op_node); + + value_ele = axiom_element_create(env, op_node, "in1", NULL, &value_node); + sprintf(value_str, "%d", result); + axiom_element_set_text(value_ele, env, value_str, value_node); + + return op_node; + +} + +/** + * Auto generated function definition + + * @param param2 + +*/ +axiom_node_t * +axis2_skel_Calculator_div( + const axutil_env_t * env, + axiom_node_t * param2) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param4 + +*/ +axiom_node_t * +axis2_skel_Calculator_sub( + const axutil_env_t * env, + axiom_node_t * param4) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param6 + +*/ +axiom_node_t * +axis2_skel_Calculator_mul( + const axutil_env_t * env, + axiom_node_t * param6) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} diff --git a/samples/codegen/server/calc_xml_inout/readme b/samples/codegen/server/calc_xml_inout/readme new file mode 100644 index 0000000..e4cecdf --- /dev/null +++ b/samples/codegen/server/calc_xml_inout/readme @@ -0,0 +1,12 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/Calculator.wsdl + +Command to execute the code generation: + +WSDL2C.sh -uri Calculator.wsdl -u -d none -ss +WSDL2C.bat -uri Calculator.wsdl -u -d none -ss + +Please check the instruction of $AXIS2C_SRC_HOME/tools/codegen/javatool/README.txt +on how to use the script diff --git a/samples/codegen/server/calculator/Makefile.am b/samples/codegen/server/calculator/Makefile.am new file mode 100644 index 0000000..308673c --- /dev/null +++ b/samples/codegen/server/calculator/Makefile.am @@ -0,0 +1,15 @@ +prglibdir=$(prefix)/services/Calculator +samplesdir=$(prefix)/samples/server/Calculator +prglib_LTLIBRARIES = libCalculator.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml +SUBDIRS = +libCalculator_la_SOURCES = \ +axis2_add.c axis2_Calculator.c axis2_divResponse16.c axis2_mulResponse14.c axis2_subResponse12.c \ +axis2_addRequest.c axis2_Calculator_svc_skeleton.c axis2_divResponse.c axis2_mulResponse.c axis2_subResponse.c \ +axis2_addResponse20.c axis2_div.c axis2_mul.c axis2_sub.c \ +axis2_addResponse.c axis2_divRequest.c axis2_mulRequest.c axis2_subRequest.c +libCalculator_la_LIBADD = +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/server/calculator/axis2_skel_Calculator.c b/samples/codegen/server/calculator/axis2_skel_Calculator.c new file mode 100644 index 0000000..70d6da4 --- /dev/null +++ b/samples/codegen/server/calculator/axis2_skel_Calculator.c @@ -0,0 +1,158 @@ + + + /** + * axis2_skel_Calculator.c + * + * This file was auto-generated from WSDL for "Calculator|http://localhost/axis/Calculator" service + * by the Apache Axis2/C version: #axisVersion# #today# + * axis2_skel_Calculator Axis2/C skeleton for the axisService + */ + + #include "axis2_skel_Calculator.h" + + + + + /** + * auto generated function definition signature + * for "div|http://localhost/axis/Calculator" operation. + + * @param div + */ + + adb_divResponse_t* axis2_skel_Calculator_div (const axutil_env_t *env, + adb_div_t *_div1) + { + + + adb_divResponse_t *_divresponse2; + int int_2; + + int int_0; + int int_1; + + /* Extract the request */ + + int_0 = adb_div_get_in0(_div1, env); + printf("Returned int: %d\n", int_0); + int_1 = adb_div_get_in1(_div1, env); + printf("Returned int: %d\n", int_1); + + /* Build the response adb */ + + _divresponse2 = adb_divResponse_create(env); + int_2 = int_0 / int_1; + adb_divResponse_set_divReturn(_divresponse2, env, int_2); + + return _divresponse2; + } + + + + /** + * auto generated function definition signature + * for "mul|http://localhost/axis/Calculator" operation. + + * @param mul + */ + + adb_mulResponse_t* axis2_skel_Calculator_mul (const axutil_env_t *env, + adb_mul_t *_mul1) + { + + + adb_mulResponse_t *_mulresponse2; + int int_5; + + int int_3; + int int_4; + + /* Extract the request */ + + int_3 = adb_mul_get_in0(_mul1, env); + printf("Returned int: %d\n", int_3); + int_4 = adb_mul_get_in1(_mul1, env); + printf("Returned int: %d\n", int_4); + + /* Build the response adb */ + + _mulresponse2 = adb_mulResponse_create(env); + int_5 = int_3 * int_4; + adb_mulResponse_set_mulReturn(_mulresponse2, env, int_5); + + return _mulresponse2; + } + + + + /** + * auto generated function definition signature + * for "add|http://localhost/axis/Calculator" operation. + + * @param add + */ + + adb_addResponse_t* axis2_skel_Calculator_add (const axutil_env_t *env, + adb_add_t *_add1) + { + + + adb_addResponse_t *_addresponse2; + int int_8; + + int int_6; + int int_7; + + /* Extract the request */ + + int_6 = adb_add_get_in0(_add1, env); + printf("Returned int: %d\n", int_6); + int_7 = adb_add_get_in1(_add1, env); + printf("Returned int: %d\n", int_7); + + /* Build the response adb */ + + _addresponse2 = adb_addResponse_create(env); + int_8 = int_6 + int_7; + adb_addResponse_set_addReturn(_addresponse2, env, int_8); + + return _addresponse2; + } + + + + /** + * auto generated function definition signature + * for "sub|http://localhost/axis/Calculator" operation. + + * @param sub + */ + + adb_subResponse_t* axis2_skel_Calculator_sub (const axutil_env_t *env, + adb_sub_t *_sub1) + { + + + adb_subResponse_t *_subresponse2; + int int_11; + + int int_9; + int int_10; + + /* Extract the request */ + + int_9 = adb_sub_get_in0(_sub1, env); + printf("Returned int: %d\n", int_9); + int_10 = adb_sub_get_in1(_sub1, env); + printf("Returned int: %d\n", int_10); + + /* Build the response adb */ + + _subresponse2 = adb_subResponse_create(env); + int_11 = int_9 - int_10; + adb_subResponse_set_subReturn(_subresponse2, env, int_11); + + return _subresponse2; + } + + diff --git a/samples/codegen/server/calculator/readme b/samples/codegen/server/calculator/readme new file mode 100644 index 0000000..49b34bc --- /dev/null +++ b/samples/codegen/server/calculator/readme @@ -0,0 +1,12 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/Calculator.wsdl + +Command to execute the code generation: + +WSDL2C.sh -uri Calculator.wsdl -u -d adb -ss +WSDL2C.bat -uri Calculator.wsdl -u -d adb -ss + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt +on how to use the script diff --git a/samples/codegen/server/interop_doc1/Makefile.am b/samples/codegen/server/interop_doc1/Makefile.am new file mode 100644 index 0000000..1abe530 --- /dev/null +++ b/samples/codegen/server/interop_doc1/Makefile.am @@ -0,0 +1,23 @@ +prglibdir=$(prefix)/services/interop_doc1 +samplesdir=$(prefix)/samples/server/interop_doc1 +prglib_LTLIBRARIES = libInteropTestPortTypeDocService.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml +SUBDIRS = +libInteropTestPortTypeDocService_la_SOURCES = \ +axis2_echoBase64.c axis2_echoFloatResponse.c axis2_echoStructArray.c \ +axis2_echoBase64Response.c axis2_echoHexBinary.c axis2_echoStructArrayResponse.c \ +axis2_echoBoolean.c axis2_echoHexBinaryResponse.c axis2_echoStruct.c \ +axis2_echoBooleanResponse.c axis2_echoIntegerArray.c axis2_echoStructResponse.c \ +axis2_echoDate.c axis2_echoIntegerArrayResponse.c axis2_echoVoid.c \ +axis2_echoDateResponse.c axis2_echoInteger.c axis2_echoVoidResponse.c \ +axis2_echoDecimal.c axis2_echoIntegerResponse.c axis2_InteropTestPortTypeDocService.c \ +axis2_echoDecimalResponse.c axis2_echoStringArray.c axis2_InteropTestPortTypeDocService_svc_skeleton.c \ +axis2_echoFloatArray.c axis2_echoStringArrayResponse.c axis2_SOAPStruct.c \ +axis2_echoFloatArrayResponse.c axis2_echoString.c \ +axis2_echoFloat.c axis2_echoStringResponse.c + +libInteropTestPortTypeDocService_la_LIBADD = +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/server/interop_doc1/axis2_skel_InteropTestPortTypeDocService.c b/samples/codegen/server/interop_doc1/axis2_skel_InteropTestPortTypeDocService.c new file mode 100644 index 0000000..6b31079 --- /dev/null +++ b/samples/codegen/server/interop_doc1/axis2_skel_InteropTestPortTypeDocService.c @@ -0,0 +1,274 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * axis2_skel_InteropTestPortTypeDocService.c + * + * This file was auto-generated from WSDL + * by the Apache Axis2/Java version: #axisVersion# #today# + * axis2_skel_InteropTestPortTypeDocService Axis2/C skeleton for the axisService + */ + +#include "axis2_skel_InteropTestPortTypeDocService.h" + +/** + * Auto generated function definition + + * @param param0 + + */ +adb_echoFloatResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoFloat( + const axutil_env_t * env, + adb_echoFloat_t * param0) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param2 + + */ +adb_echoVoidResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoVoid( + const axutil_env_t * env, + adb_echoVoid_t * param2) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param4 + + */ +adb_echoDateResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoDate( + const axutil_env_t * env, + adb_echoDate_t * param4) +{ + /* Todo fill this with the necessary business logic */ + adb_echoDate_t *echo_in = param4; + adb_echoDateResponse_t *echo_out = NULL; + + axutil_date_time_t *echo_date = NULL; + axis2_char_t *recieved_date_str = NULL; + + echo_date = adb_echoDate_get_arg_0_10(echo_in, env); + + recieved_date_str = axutil_date_time_serialize_date_time(echo_date, env); + printf("echoing date %s\n", recieved_date_str); + + echo_out = adb_echoDateResponse_create(env); + adb_echoDateResponse_set_echodatereturn(echo_out, env, echo_date); + + return echo_out; +} + +/** + * Auto generated function definition + + * @param param6 + + */ +adb_echoDecimalResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoDecimal( + const axutil_env_t * env, + adb_echoDecimal_t * param6) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param8 + + */ +adb_echoStringResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoString( + const axutil_env_t * env, + adb_echoString_t * param8) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param10 + + */ +adb_echoBase64Response_t * +axis2_skel_InteropTestPortTypeDocService_echoBase64( + const axutil_env_t * env, + adb_echoBase64_t * param10) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param12 + + */ +adb_echoFloatArrayResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoFloatArray( + const axutil_env_t * env, + adb_echoFloatArray_t * param12) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param14 + + */ +adb_echoIntegerArrayResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoIntegerArray( + const axutil_env_t * env, + adb_echoIntegerArray_t * param14) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param16 + + */ +adb_echoHexBinaryResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoHexBinary( + const axutil_env_t * env, + adb_echoHexBinary_t * param16) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param18 + + */ +adb_echoIntegerResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoInteger( + const axutil_env_t * env, + adb_echoInteger_t * param18) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param20 + + */ +adb_echoBooleanResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoBoolean( + const axutil_env_t * env, + adb_echoBoolean_t * param20) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param22 + + */ +adb_echoStringArrayResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoStringArray( + const axutil_env_t * env, + adb_echoStringArray_t * param22) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param24 + + */ +adb_echoStructArrayResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoStructArray( + const axutil_env_t * env, + adb_echoStructArray_t * param24) +{ + /* Todo fill this with the necessary business logic */ + adb_echoStructArray_t *echo_in = param24; + adb_echoStructArrayResponse_t *echo_out = NULL; + + adb_SOAPStruct_t *echo_struct = NULL; + int arr_size = 0; + + int i = 0; + + arr_size = adb_echoStructArray_sizeof_arg_0_7(echo_in, env); + echo_out = adb_echoStructArrayResponse_create(env); + for (i = 0; i < arr_size; i++) + { + echo_struct = + adb_echoStructArray_get_arg_0_7_at(echo_in, env, i); + printf("echoing turn %d\n string %s\n int %d\n float %f\n\n", i, + adb_SOAPStruct_get_varString(echo_struct, env), + adb_SOAPStruct_get_varInt(echo_struct, env), + adb_SOAPStruct_get_varFloat(echo_struct, env)); + + adb_echoStructArrayresponse_add_echoStructArrayreturn + (echo_out, env, echo_struct); + } + return echo_out; + +} + +/** + * Auto generated function definition + + * @param param26 + + */ +adb_echoStructResponse_t * +axis2_skel_InteropTestPortTypeDocService_echoStruct( + const axutil_env_t * env, + adb_echoStruct_t * param26) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} diff --git a/samples/codegen/server/interop_doc1/readme b/samples/codegen/server/interop_doc1/readme new file mode 100644 index 0000000..f7c262e --- /dev/null +++ b/samples/codegen/server/interop_doc1/readme @@ -0,0 +1,10 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +wsdl $AXIS2C_SRC_HOME/test/resources/wsdl/InteropTestRound1Doc.wsdl + +Command to execute the code generation: +WSDL2C.sh -uri Calculator.wsdl -u -d adb -ss +WSDL2C.bat -uri Calculator.wsdl -u -d adb -ss + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt diff --git a/samples/codegen/server/interop_doc2/Makefile.am b/samples/codegen/server/interop_doc2/Makefile.am new file mode 100644 index 0000000..7b46d88 --- /dev/null +++ b/samples/codegen/server/interop_doc2/Makefile.am @@ -0,0 +1,16 @@ +prglibdir=$(prefix)/services/interop_doc2 +samplesdir=$(prefix)/samples/server/interop_doc2 +prglib_LTLIBRARIES = libWSDLInteropTestDocLitService.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml +SUBDIRS = +libWSDLInteropTestDocLitService_la_SOURCES = \ +axis2_ArrayOfstring_literal.c axis2_echoStringResponse.c axis2_echoVoidResponse.c \ +axis2_echoStringArray.c axis2_echoStruct.c axis2_SOAPStruct.c \ +axis2_echoStringArrayResponse.c axis2_echoStructResponse.c axis2_WSDLInteropTestDocLitService.c \ +axis2_echoString.c axis2_echoVoid.c axis2_WSDLInteropTestDocLitService_svc_skeleton.c + +libWSDLInteropTestDocLitService_la_LIBADD = +INCLUDES = -I$(AXIS2C_HOME)/include \ + @UTILINC@ \ + @AXIOMINC@ diff --git a/samples/codegen/server/interop_doc2/axis2_skel_WSDLInteropTestDocLitService.c b/samples/codegen/server/interop_doc2/axis2_skel_WSDLInteropTestDocLitService.c new file mode 100644 index 0000000..f6b818a --- /dev/null +++ b/samples/codegen/server/interop_doc2/axis2_skel_WSDLInteropTestDocLitService.c @@ -0,0 +1,139 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * axis2_WSDLInteropTestDocLitService.c + * + * This file was auto-generated from WSDL + * by the Apache Axis2/Java version: #axisVersion# #today# + * axis2_WSDLInteropTestDocLitService Axis2/C skeleton for the axisService + */ + +#include "axis2_WSDLInteropTestDocLitService.h" + +/** + * Auto generated function definition + + * @param param0 + + */ +axis2_echoVoidResponse_t * +axis2_WSDLInteropTestDocLitService_echoVoid( + const axutil_env_t * env, + axis2_echoVoid_t * param0) +{ + /* Todo fill this with the necessary business logic */ + return NULL; +} + +/** + * Auto generated function definition + + * @param param2 + + */ +axis2_echoStringArrayResponse_t * +axis2_WSDLInteropTestDocLitService_echoStringArray( + const axutil_env_t * env, + axis2_echoStringArray_t * param2) +{ + /* Todo fill this with the necessary business logic */ + axis2_echoStringArray_t *echo_in = param2; + axis2_echoStringArrayResponse_t *echo_out = NULL; + axis2_ArrayOfstring_literal_t *array_in = NULL; + axis2_ArrayOfstring_literal_t *array_out = NULL; + char **string_array = NULL; + int string_array_length = 0; + + array_in = AXIS2_ECHOSTRINGARRAY_GET_PARAM0(echo_in, env); + string_array = AXIS2_ARRAYOFSTRING_LITERAL_GET_STRING(array_in, env, + &string_array_length); + + array_out = axis2_ArrayOfstring_literal_create(env); + AXIS2_ARRAYOFSTRING_LITERAL_SET_STRING(array_out, env, + string_array, string_array_length); + echo_out = axis2_echoStringArrayResponse_create(env); + + AXIS2_ECHOSTRINGARRAYRESPONSE_SET_RETURN(echo_out, env, array_out); + + return echo_out; + +} + +/** + * Auto generated function definition + + * @param param4 + + */ +axis2_echoStructResponse_t * +axis2_WSDLInteropTestDocLitService_echoStruct( + const axutil_env_t * env, + axis2_echoStruct_t * param4) +{ + /* Todo fill this with the necessary business logic */ + axis2_echoStruct_t *echo_in = param4; + axis2_echoStructResponse_t *echo_out = NULL; + axis2_SOAPStruct_t *struct_in = NULL; + axis2_SOAPStruct_t *struct_out = NULL; + + float float_val = 0; + int int_val = 0; + char *string_val = NULL; + + struct_in = AXIS2_ECHOSTRUCT_GET_PARAM0(echo_in, env); + + float_val = AXIS2_SOAPSTRUCT_GET_VARFLOAT(struct_in, env); + int_val = AXIS2_SOAPSTRUCT_GET_VARINT(struct_in, env); + string_val = AXIS2_SOAPSTRUCT_GET_VARSTRING(struct_in, env); + + struct_out = axis2_SOAPStruct_create(env); + AXIS2_SOAPSTRUCT_SET_VARFLOAT(struct_out, env, float_val); + AXIS2_SOAPSTRUCT_SET_VARINT(struct_out, env, int_val); + AXIS2_SOAPSTRUCT_SET_VARSTRING(struct_out, env, string_val); + + echo_out = axis2_echoStructResponse_create(env); + AXIS2_ECHOSTRUCTRESPONSE_SET_RETURN(echo_out, env, struct_out); + + return echo_out; +} + +/** + * Auto generated function definition + + * @param param6 + + */ +axis2_echoStringResponse_t * +axis2_WSDLInteropTestDocLitService_echoString( + const axutil_env_t * env, + axis2_echoString_t * param6) +{ + /* Todo fill this with the necessary business logic */ + axis2_echoString_t *echo_in = param6; + axis2_echoStringResponse_t *echo_out = NULL; + + char *echo_string = NULL; + + echo_string = AXIS2_ECHOSTRING_GET_PARAM0(echo_in, env); + + echo_out = axis2_echoStringResponse_create(env); + AXIS2_ECHOSTRUCTRESPONSE_SET_RETURN(echo_out, env, echo_string); + + return echo_out; +} diff --git a/samples/codegen/server/interop_doc2/readme b/samples/codegen/server/interop_doc2/readme new file mode 100644 index 0000000..51f3c59 --- /dev/null +++ b/samples/codegen/server/interop_doc2/readme @@ -0,0 +1,10 @@ +This sample demonstrates the use of code generation using Axis2/Java WSDL2Java +tool (Axis2/Java source revision 414253). + +wsdl $AXIS2C_HOME/test/resources/wsdl/interoptestdoclitparameters.wsdl + +Command to execute the code generation: +WSDL2C.sh -uri Calculator.wsdl -u -d adb -ss +WSDL2C.bat -uri Calculator.wsdl -u -d adb -ss + +Please check the instruction of $AXIS2C_SRC_HOME/c/tools/codegen/javatool/README.txt diff --git a/samples/configure.ac b/samples/configure.ac new file mode 100644 index 0000000..734e88c --- /dev/null +++ b/samples/configure.ac @@ -0,0 +1,154 @@ +dnl run autogen.sh to generate the configure script. + +AC_PREREQ(2.59) + +AC_INIT(axis2c-sample-src, 1.6.0) +AC_CANONICAL_SYSTEM +AM_CONFIG_HEADER(config.h) +dnl AM_INIT_AUTOMAKE([tar-ustar]) +AM_INIT_AUTOMAKE +m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])]) +AC_PREFIX_DEFAULT(/usr/local/axis2c) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_CPP +AC_PROG_LIBTOOL +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET + +dnl check for flavours of varargs macros (test from GLib) +AC_MSG_CHECKING(for ISO C99 varargs macros in C) +AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(...) a(1,__VA_ARGS__) +call_a(2,3); +],axis2c_have_iso_c_varargs=yes,axis2c_have_iso_c_varargs=no) +AC_MSG_RESULT($axis2c_have_iso_c_varargs) + +AC_MSG_CHECKING(for GNUC varargs macros) +AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(params...) a(1,params) +call_a(2,3); +],axis2c_have_gnuc_varargs=yes,axis2c_have_gnuc_varargs=no) +AC_MSG_RESULT($axis2c_have_gnuc_varargs) + +dnl Output varargs tests +if test x$axis2c_have_iso_c_varargs = xyes; then + AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros]) +fi +if test x$axis2c_have_gnuc_varargs = xyes; then + AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros]) +fi + +dnl Checks for libraries. +AC_CHECK_LIB(dl, dlopen) + +CFLAGS="$CFLAGS -ansi -Wall -D_LARGEFILE64_SOURCE -Wno-implicit-function-declaration" + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdio.h stdlib.h string.h]) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +dnl Checks for library functions. +dnl AC_FUNC_MALLOC +dnl AC_FUNC_REALLOC + +CFLAGS="$CFLAGS $GUTHTHILA_CFLAGS" + +AC_MSG_CHECKING(whether to build dynamic invocation client) +AC_ARG_ENABLE(diclient, [ --enable-diclient build diclient. default=no], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + DICLIENT_DIR="" + ;; + *) + AC_MSG_RESULT(yes) + DICLIENT_DIR="diclient" + + ;; + esac ], + AC_MSG_RESULT(yes) + DICLIENT_DIR="" +) + +AC_MSG_CHECKING(To Use Axis2 C . This is a compulsory module to build Axis2 C samples) +AC_ARG_WITH(axis2, +[ --with-axis2[=PATH] Find the AXIS2 header files in 'PATH'. + 'PATH' should point to AXIS2 include files location. + If you omit the '=PATH' part completely, the configure script will search + '${AXIS2C_HOME}/include/axis2-1.6.0' for AXIS2 headers.], +[ case "$withval" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + dnl Find axis2 include dir in the path + if test -d $withval; then + axis2inc="-I$withval" + dnl else find the axiom include dir in ${AXIS2C_HOME}/include + elif test -d "${AXIS2C_HOME}/include"; then + axis2inc="-I${AXIS2C_HOME}/include/axis2-1.6.0" + else + AC_MSG_ERROR(could not find axis2. stop) + fi + ;; + esac ], + if test -d "${AXIS2C_HOME}/include"; then + axis2inc="-I${AXIS2C_HOME}/include/axis2-1.6.0" + fi + AC_MSG_RESULT(no) +) + +APACHE2INC=$apache2inc +AXIS2INC=$axis2inc +APRINC=$aprinc + +AC_SUBST(APACHE2INC) +AC_SUBST(APRINC) +AC_SUBST(AXIS2INC) +AC_SUBST(GUTHTHILA_DIR) +AC_SUBST(GUTHTHILA_LIBS) +AC_SUBST(DICLIENT_DIR) + +AC_CONFIG_FILES([Makefile \ + server/Makefile \ + server/echo/Makefile \ + server/math/Makefile \ + server/version/Makefile \ + server/Calculator/Makefile \ + server/notify/Makefile \ + server/sg_math/Makefile \ + server/mtom/Makefile \ + server/mtom_callback/Makefile \ + client/Makefile \ + client/echo/Makefile \ + client/math/Makefile \ + client/version/Makefile \ + client/mtom/Makefile \ + client/mtom_callback/Makefile \ + client/mtom/resources/Makefile \ + client/notify/Makefile \ + client/google/Makefile \ + client/yahoo/Makefile \ + client/amqp/Makefile \ + client/amqp/echo/Makefile \ + client/amqp/notify/Makefile \ + client/amqp/mtom/Makefile \ + client/amqp/mtom/resources/Makefile \ + user_guide/Makefile \ + user_guide/clients/Makefile \ + mtom_caching_callback/Makefile \ + mtom_sending_callback/Makefile + ]) + +AC_OUTPUT + diff --git a/samples/mtom_caching_callback/Makefile.am b/samples/mtom_caching_callback/Makefile.am new file mode 100644 index 0000000..1d8b2a9 --- /dev/null +++ b/samples/mtom_caching_callback/Makefile.am @@ -0,0 +1,10 @@ +prglibdir=$(prefix)/samples/lib/mtom_caching_callback +prglib_LTLIBRARIES = libmtom_caching_callback.la +libmtom_caching_callback_la_SOURCES = mtom_caching_callback.c +libmtom_caching_callback_la_LIBADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil + +INCLUDES = -I ../../util/include \ + -I ../../axiom/include \ + @AXIS2INC@ diff --git a/samples/mtom_caching_callback/mtom_caching_callback.c b/samples/mtom_caching_callback/mtom_caching_callback.c new file mode 100644 index 0000000..03ee358 --- /dev/null +++ b/samples/mtom_caching_callback/mtom_caching_callback.c @@ -0,0 +1,184 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +caching_callback_free(axiom_mtom_caching_callback_t *caching_callback, + const axutil_env_t* env) +{ + if (caching_callback) + { + if (caching_callback->ops) + { + AXIS2_FREE(env->allocator, caching_callback->ops); + } + AXIS2_FREE(env->allocator, caching_callback); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN void* AXIS2_CALL +caching_callback_init_handler(axiom_mtom_caching_callback_t *caching_callback, + const axutil_env_t* env, + axis2_char_t *key) +{ + FILE *fp = NULL; + axis2_char_t *file_name = NULL; + axis2_char_t *encoded_key = NULL; + + if(caching_callback->user_param) + { + /* If this is set the callback implementer may use + it to create the void return value at the end of + this function. + */ + } + + if(key) + { + /*encoded_key = axutil_strdup(env, key);*/ + encoded_key = AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t ))* (strlen(key))); + memset(encoded_key, 0, strlen(key)); + + if(encoded_key) + { + encoded_key = axutil_url_encode(env, encoded_key, key, (int)strlen(key)); + } + + file_name = axutil_stracat(env, "/opt/tmp/", encoded_key); + /*file_name = key;*/ + if(file_name) + { + fp = fopen(file_name, "ab+"); + } + else + { + return NULL; + } + } + + #if !defined(WIN32) + { + axis2_char_t permission_str[256]; + sprintf(permission_str, "chmod 777 %s", file_name); + system(permission_str); + } + #endif + + if(encoded_key) + { + AXIS2_FREE(env->allocator, encoded_key); + encoded_key = NULL; + } + + + if(file_name) + { + AXIS2_FREE(env->allocator, file_name); + file_name = NULL; + } + + return (void *)fp; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +caching_callback_cache(axiom_mtom_caching_callback_t *caching_callback, + const axutil_env_t* env, + axis2_char_t *buf, + int buf_len, + void* handler) +{ + size_t len = 0; + FILE *fp = (FILE *)(handler); + + + len = fwrite(buf, 1, buf_len, fp); + if(len < 0) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; + +} + + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +caching_callback_close_handler(axiom_mtom_caching_callback_t *caching_callback, + const axutil_env_t* env, + void* handler) +{ + axis2_status_t status = AXIS2_SUCCESS; + + if(fclose((FILE *)handler) != 0) + { + status = AXIS2_FAILURE; + } + return status; +} + + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance(axiom_mtom_caching_callback_t **inst, + const axutil_env_t *env) +{ + axiom_mtom_caching_callback_t* caching_callback = NULL; + + caching_callback = AXIS2_MALLOC(env->allocator, + sizeof(axiom_mtom_caching_callback_t)); + + caching_callback->ops = AXIS2_MALLOC( + env->allocator, sizeof(axiom_mtom_caching_callback_ops_t)); + + /*assign function pointers*/ + + caching_callback->ops->init_handler = caching_callback_init_handler; + caching_callback->ops->cache = caching_callback_cache; + caching_callback->ops->close_handler = caching_callback_close_handler; + caching_callback->ops->free = caching_callback_free; + + *inst = caching_callback; + + if (!(*inst)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Cannot load the caching callback"); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int axis2_remove_instance(axiom_mtom_caching_callback_t *inst, + const axutil_env_t *env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIOM_MTOM_CACHING_CALLBACK_FREE(inst, env); + } + return status; +} diff --git a/samples/mtom_sending_callback/Makefile.am b/samples/mtom_sending_callback/Makefile.am new file mode 100644 index 0000000..991bff9 --- /dev/null +++ b/samples/mtom_sending_callback/Makefile.am @@ -0,0 +1,11 @@ +prglibdir=$(prefix)/samples/lib/mtom_sending_callback +prglib_LTLIBRARIES = libmtom_sending_callback.la +libmtom_sending_callback_la_SOURCES = mtom_sending_callback.c +libmtom_sending_callback_la_LIBADD = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil + +INCLUDES = -I ../../util/include \ + -I ../../axiom/include \ + -I /usr/include/mysql \ + @AXIS2INC@ diff --git a/samples/mtom_sending_callback/mtom_sending_callback.c b/samples/mtom_sending_callback/mtom_sending_callback.c new file mode 100644 index 0000000..7182008 --- /dev/null +++ b/samples/mtom_sending_callback/mtom_sending_callback.c @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#define MAX_BUFFER_SIZE 1024 + +struct storage_handler +{ + FILE *fp; + int storage_size; + axis2_char_t *buffer; + int buffer_size; +}; +typedef struct storage_handler storage_handler_t; + + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +mtom_sending_callback_free(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env) +{ + if (mtom_sending_callback) + { + if (mtom_sending_callback->ops) + { + AXIS2_FREE(env->allocator, mtom_sending_callback->ops); + } + AXIS2_FREE(env->allocator, mtom_sending_callback); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN void* AXIS2_CALL +mtom_sending_callback_init_handler(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *user_param) +{ + axis2_char_t *file_name = NULL; + storage_handler_t *storage_handler = NULL; + struct stat stat_p; + + if(user_param) + { + /*file_name = axutil_stracat(env, "/tmp/", (axis2_char_t *)user_param);*/ + file_name = (axis2_char_t *)user_param; + } + else + { + return NULL; + } + + if (stat(file_name, &stat_p) == -1) + { + return NULL; + } + + storage_handler = AXIS2_MALLOC(env->allocator, + sizeof(storage_handler_t)); + + storage_handler->fp = fopen(file_name, "rb"); + storage_handler->storage_size = stat_p.st_size; + + if(storage_handler->storage_size > MAX_BUFFER_SIZE) + { + storage_handler->buffer_size = MAX_BUFFER_SIZE; + } + else + { + storage_handler->buffer_size = storage_handler->storage_size; + } + + storage_handler->buffer = (axis2_char_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_char_t)*(storage_handler->buffer_size)); + + /* + #if !defined(WIN32) + { + axis2_char_t permission_str[256]; + sprintf(permission_str, "chmod 777 %s", file_name); + system(permission_str); + } + #endif + */ + + /*if(file_name) + { + AXIS2_FREE(env->allocator, file_name); + file_name = NULL; + }*/ + + return (void *)storage_handler; +} + +AXIS2_EXTERN int AXIS2_CALL +mtom_sending_callback_load_data(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *handler, + axis2_char_t **buffer) +{ + int len = 0; + FILE *fp = ((storage_handler_t *)(handler))->fp; + storage_handler_t *storage_handler = NULL; + + storage_handler = (storage_handler_t *)handler; + + memset(storage_handler->buffer, 0, storage_handler->buffer_size); + + if(feof(fp)) + { + return 0; + } + else + { + len = (int)fread(storage_handler->buffer, 1, + storage_handler->buffer_size, fp); + } + + *buffer = storage_handler->buffer; + return len; +} + + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +mtom_sending_callback_close_handler(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void* handler) +{ + axis2_status_t status = AXIS2_SUCCESS; + storage_handler_t *storage_handler = NULL; + + storage_handler = (storage_handler_t *)handler; + + if(fclose(storage_handler->fp) != 0) + { + status = AXIS2_FAILURE; + } + + AXIS2_FREE(env->allocator, storage_handler->buffer); + storage_handler->buffer = NULL; + + AXIS2_FREE(env->allocator, storage_handler); + storage_handler = NULL; + + return status; +} + + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance(axiom_mtom_sending_callback_t **inst, + const axutil_env_t *env) +{ + axiom_mtom_sending_callback_t* mtom_sending_callback = NULL; + + mtom_sending_callback = AXIS2_MALLOC(env->allocator, + sizeof(axiom_mtom_sending_callback_t)); + + mtom_sending_callback->ops = AXIS2_MALLOC( + env->allocator, sizeof(axiom_mtom_sending_callback_ops_t)); + + /*assign function pointers*/ + + mtom_sending_callback->ops->init_handler = mtom_sending_callback_init_handler; + mtom_sending_callback->ops->load_data = mtom_sending_callback_load_data; + mtom_sending_callback->ops->close_handler = mtom_sending_callback_close_handler; + mtom_sending_callback->ops->free = mtom_sending_callback_free; + + *inst = mtom_sending_callback; + + if (!(*inst)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Cannot load the mtom_sending callback"); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int axis2_remove_instance(axiom_mtom_sending_callback_t *inst, + const axutil_env_t *env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIOM_MTOM_SENDING_CALLBACK_FREE(inst, env); + } + return status; +} diff --git a/samples/server/Calculator/Calculator.mk b/samples/server/Calculator/Calculator.mk new file mode 100644 index 0000000..8b4c683 --- /dev/null +++ b/samples/server/Calculator/Calculator.mk @@ -0,0 +1,7 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:Calculator.dll + + + + diff --git a/samples/server/Calculator/Calculator.wsdl b/samples/server/Calculator/Calculator.wsdl new file mode 100644 index 0000000..a37e390 --- /dev/null +++ b/samples/server/Calculator/Calculator.wsdl @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/server/Calculator/Makefile.am b/samples/server/Calculator/Makefile.am new file mode 100644 index 0000000..65f95ce --- /dev/null +++ b/samples/server/Calculator/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/Calculator +prglib_LTLIBRARIES = libCalculator.la +prglib_DATA=services.xml Calculator.wsdl +EXTRA_DIST = services.xml Calculator.wsdl Calculator.mk calc.h +noinst_HEADERS = calc.h +SUBDIRS = +libCalculator_la_SOURCES = calc.c calc_skeleton.c +libCalculator_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/Calculator/calc.c b/samples/server/Calculator/calc.c new file mode 100644 index 0000000..3e5eeba --- /dev/null +++ b/samples/server/Calculator/calc.c @@ -0,0 +1,553 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "calc.h" +#include + +axiom_node_t * +axis2_calc_add( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *complex_node = NULL; + axiom_node_t *seq_node = NULL; + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Calculator client request ERROR: input parameter NULL\n"); + return NULL; + } + complex_node = axiom_node_get_first_child(node, env); + if (!complex_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + seq_node = axiom_node_get_first_child(complex_node, env); + if (!seq_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(seq_node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 + param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_calc_sub( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Calculator client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 - param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_calc_mul( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Calculator client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 * param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_calc_div( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Calculator client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + if (param2 == 0) + return NULL; + result = param1 / param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Calculator service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/Calculator/calc.h b/samples/server/Calculator/calc.h new file mode 100644 index 0000000..58ffde8 --- /dev/null +++ b/samples/server/Calculator/calc.h @@ -0,0 +1,41 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CALC_H +#define CALC_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_calc_add( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_calc_sub( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_calc_mul( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_calc_div( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* CALC_H */ diff --git a/samples/server/Calculator/calc_skeleton.c b/samples/server/Calculator/calc_skeleton.c new file mode 100644 index 0000000..c153eee --- /dev/null +++ b/samples/server/Calculator/calc_skeleton.c @@ -0,0 +1,157 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "calc.h" +#include +#include + +int AXIS2_CALL calc_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL calc_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL calc_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t calc_svc_skeleton_ops_var = { + calc_init, + calc_invoke, + NULL, + calc_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_calc_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &calc_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +calc_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of calc goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +calc_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +calc_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding calc method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "add") == 0) + return axis2_calc_add(env, node); + if (axutil_strcmp(op_name, "sub") == 0) + return axis2_calc_sub(env, node); + if (axutil_strcmp(op_name, "mul") == 0) + return axis2_calc_mul(env, node); + if (axutil_strcmp(op_name, "div") == 0) + return axis2_calc_div(env, node); + } + } + } + } + + printf("Calculator service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = axis2_calc_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/Calculator/services.xml b/samples/server/Calculator/services.xml new file mode 100644 index 0000000..b449764 --- /dev/null +++ b/samples/server/Calculator/services.xml @@ -0,0 +1,28 @@ + + Calculator + + + This is a testing service, named 'Calculator' to test dynamic client + + + + + Calculator#add + + + + + Calculator#sub + + + + + Calculator#mul + + + + + Calculator#div + + + diff --git a/samples/server/Makefile.am b/samples/server/Makefile.am new file mode 100644 index 0000000..677aad9 --- /dev/null +++ b/samples/server/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = echo math notify sg_math mtom Calculator version mtom_callback +EXTRA_DIST = axis2.xml diff --git a/samples/server/axis2.log b/samples/server/axis2.log new file mode 100644 index 0000000..39cdd0d --- /dev/null +++ b/samples/server/axis2.log @@ -0,0 +1 @@ +- diff --git a/samples/server/axis2.xml b/samples/server/axis2.xml new file mode 100644 index 0000000..0851e3b --- /dev/null +++ b/samples/server/axis2.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + 6060 + false + + + + + + + + + + + + + HTTP/1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/server/echo/Makefile.am b/samples/server/echo/Makefile.am new file mode 100644 index 0000000..8413c5a --- /dev/null +++ b/samples/server/echo/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/echo +prglib_LTLIBRARIES = libecho.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml echo.mk echo.h +noinst_HEADERS = echo.h +SUBDIRS = +libecho_la_SOURCES = echo.c echo_skeleton.c +libecho_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/echo/echo.c b/samples/server/echo/echo.c new file mode 100644 index 0000000..2ce6a08 --- /dev/null +++ b/samples/server/echo/echo.c @@ -0,0 +1,116 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "echo.h" +#include +#include + +axiom_node_t *build_om_programatically( + const axutil_env_t * env, + axis2_char_t * text); + +void set_custom_error( + const axutil_env_t * env, + axis2_char_t * error_message); + +axiom_node_t * +axis2_echo_echo( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *text_parent_node = NULL; + axiom_node_t *text_node = NULL; + axiom_node_t *ret_node = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + /* Expected request format is :- + * + * echo5 + * + */ + if (!node) /* 'echoString' node */ + { + set_custom_error(env, "Invalid payload; echoString node is NULL"); + return NULL; + } + + text_parent_node = axiom_node_get_first_element(node, env); + if (!text_parent_node) + { + set_custom_error(env, "Invalid payload; text node is NULL"); + return NULL; + } + + text_node = axiom_node_get_first_child(text_parent_node, env); + if (!text_node) /* actual text to echo */ + { + set_custom_error(env, "Invalid payload; text to be echoed is NULL"); + return NULL; + } + + if (axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(text_node, env); + if (text && axiom_text_get_value(text, env)) + { + axis2_char_t *text_str = + (axis2_char_t *) axiom_text_get_value(text, env); + ret_node = build_om_programatically(env, text_str); + } + } + else + { + set_custom_error(env, "Invalid payload; invalid XML in request"); + return NULL; + } + + return ret_node; +} + +/* Builds the response content */ +axiom_node_t * +build_om_programatically( + const axutil_env_t * env, + axis2_char_t * text) +{ + axiom_node_t *echo_om_node = NULL; + axiom_element_t *echo_om_ele = NULL; + axiom_node_t *text_om_node = NULL; + axiom_element_t *text_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + echo_om_ele = + axiom_element_create(env, NULL, "echoString", ns1, &echo_om_node); + text_om_ele = + axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node); + axiom_element_set_text(text_om_ele, env, text, text_om_node); + return echo_om_node; +} + +void +set_custom_error( + const axutil_env_t * env, + axis2_char_t * error_message) +{ + axutil_error_set_error_message(env->error, error_message); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_LAST + 1, AXIS2_FAILURE); +} diff --git a/samples/server/echo/echo.h b/samples/server/echo/echo.h new file mode 100644 index 0000000..ecad867 --- /dev/null +++ b/samples/server/echo/echo.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CALC_H +#define CALC_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_echo_echo( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* CALC_H */ diff --git a/samples/server/echo/echo.mk b/samples/server/echo/echo.mk new file mode 100644 index 0000000..ae0f769 --- /dev/null +++ b/samples/server/echo/echo.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:echo.dll + + + + + diff --git a/samples/server/echo/echo_skeleton.c b/samples/server/echo/echo_skeleton.c new file mode 100644 index 0000000..2f902ab --- /dev/null +++ b/samples/server/echo/echo_skeleton.c @@ -0,0 +1,182 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "echo.h" +#include +#include +#include + +int AXIS2_CALL echo_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL echo_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL echo_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL echo_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t echo_svc_skeleton_ops_var = { + echo_init, + echo_invoke, + echo_on_fault, + echo_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_echo_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + /* Allocate memory for the structs */ + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &echo_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +echo_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of echo service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +echo_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only echo in this sample, hence invoke echo method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + axis2_endpoint_ref_t* to_epr = NULL; + to_epr = axis2_msg_ctx_get_to(msg_ctx, env); + + if (to_epr) + { + axis2_char_t* to_address = NULL; + to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(to_epr, env); + + if (to_address && strstr(to_address, AXIS2_ANON_SERVICE)) + { + axis2_msg_ctx_set_wsa_action(msg_ctx, env, AXIS2_ANON_OUT_IN_OP); + } + } + + return axis2_echo_echo(env, node); +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +echo_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_element_t *error_ele = NULL; + + error_ele = + axiom_element_create(env, NULL, "EchoServiceError", NULL, &error_node); + axiom_element_set_text(error_ele, env, "Echo service failed ", error_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +echo_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_echo_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/echo/services.xml b/samples/server/echo/services.xml new file mode 100644 index 0000000..ea75640 --- /dev/null +++ b/samples/server/echo/services.xml @@ -0,0 +1,34 @@ + + echo + + + + + + + + + This is a testing service, to test whether the system is working or not + + + + + http://ws.apache.org/axis2/c/samples/echoString + + + POST + echoString + + + + + + + + + + diff --git a/samples/server/math/Makefile.am b/samples/server/math/Makefile.am new file mode 100644 index 0000000..d8e6f82 --- /dev/null +++ b/samples/server/math/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/math +prglib_LTLIBRARIES = libmath.la +prglib_DATA=services.xml +EXTRA_DIST = services.xml math.mk math.h +noinst_HEADERS = math.h +SUBDIRS = +libmath_la_SOURCES = math.c math_skeleton.c +libmath_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/math/math.c b/samples/server/math/math.c new file mode 100644 index 0000000..c3236a2 --- /dev/null +++ b/samples/server/math/math.c @@ -0,0 +1,537 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "math.h" +#include + +axiom_node_t * +axis2_math_add( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 + param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_math_sub( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 - param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_math_mul( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 * param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} + +axiom_node_t * +axis2_math_div( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + if (param2 == 0) + return NULL; + result = param1 / param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/math/math.h b/samples/server/math/math.h new file mode 100644 index 0000000..58abfc5 --- /dev/null +++ b/samples/server/math/math.h @@ -0,0 +1,41 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MATH_H +#define MATH_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_math_add( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_math_sub( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_math_mul( + const axutil_env_t * env, + axiom_node_t * node); +axiom_node_t *axis2_math_div( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* MATH_H */ diff --git a/samples/server/math/math.mk b/samples/server/math/math.mk new file mode 100644 index 0000000..dee9b6d --- /dev/null +++ b/samples/server/math/math.mk @@ -0,0 +1,7 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:math.dll + + + + diff --git a/samples/server/math/math_skeleton.c b/samples/server/math/math_skeleton.c new file mode 100644 index 0000000..4aabce8 --- /dev/null +++ b/samples/server/math/math_skeleton.c @@ -0,0 +1,157 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "math.h" +#include +#include + +int AXIS2_CALL math_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL math_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL math_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t math_svc_skeleton_ops_var = { + math_init, + math_invoke, + NULL, + math_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +math_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &math_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +math_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of math goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +math_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +math_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding math method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "add") == 0) + return axis2_math_add(env, node); + if (axutil_strcmp(op_name, "sub") == 0) + return axis2_math_sub(env, node); + if (axutil_strcmp(op_name, "mul") == 0) + return axis2_math_mul(env, node); + if (axutil_strcmp(op_name, "div") == 0) + return axis2_math_div(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = math_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/math/services.xml b/samples/server/math/services.xml new file mode 100644 index 0000000..70ff77b --- /dev/null +++ b/samples/server/math/services.xml @@ -0,0 +1,18 @@ + + math + + This is a testing service, named 'math' to test multiple operations in the same service + + + + + + + + + + + + + + diff --git a/samples/server/mtom/Makefile.am b/samples/server/mtom/Makefile.am new file mode 100644 index 0000000..198cad3 --- /dev/null +++ b/samples/server/mtom/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/mtom +prglib_LTLIBRARIES = libmtom.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml mtom.mk mtom.h +noinst_HEADERS = mtom.h +SUBDIRS = +libmtom_la_SOURCES = mtom.c mtom_skeleton.c +libmtom_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/mtom/mtom.c b/samples/server/mtom/mtom.c new file mode 100644 index 0000000..f00b68b --- /dev/null +++ b/samples/server/mtom/mtom.c @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "mtom.h" +#include +#include + +axiom_node_t *build_response1( + const axutil_env_t * env, + axis2_char_t * text); + +axiom_node_t *build_response2( + const axutil_env_t *env, + axiom_data_handler_t *data_handler); + +axiom_node_t* +axis2_mtom_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx) +{ + axiom_node_t *file_name_node = NULL; + axiom_node_t *file_text_node = NULL; + axiom_node_t *ret_node = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + /* Expected request format is :- + * + test.jpg + + + + + */ + if (!node) /* 'mtomSample' node */ + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Echo client ERROR: input parameter NULL\n"); + return NULL; + } + + file_name_node = axiom_node_get_first_child(node, env); + if (!file_name_node) /* 'text' node */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Echo client ERROR: invalid XML in request\n"); + return NULL; + } + + file_text_node = axiom_node_get_first_child(file_name_node, env); + if (!file_text_node) /* actual text to mtom */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Echo client ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(file_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(file_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + axiom_node_t *image_node = NULL; + axis2_char_t *text_str = + (axis2_char_t *) axiom_text_get_value(text, env); + printf("File Name %s \n", text_str); + + image_node = axiom_node_get_next_sibling(file_name_node, env); + if (image_node) + { + /* axiom_node_t *inc_node = NULL; + inc_node = axiom_node_get_first_child(image_node, env); + if (inc_node) + { */ + axiom_node_t *binary_node = NULL; + binary_node = axiom_node_get_first_child(image_node, env); + if (binary_node) + { + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *bin_text = (axiom_text_t *) + axiom_node_get_data_element(binary_node, env); + data_handler = axiom_text_get_data_handler(bin_text, env); + if (data_handler && !axiom_data_handler_get_cached(data_handler, env)) + { + axiom_data_handler_t *data_handler_res = NULL; + axis2_byte_t *input_buff = NULL; + axis2_byte_t *buff = NULL; + size_t buff_len = 0; + + + axiom_data_handler_set_file_name(data_handler, env, + text_str); + axiom_data_handler_write_to(data_handler, env); + + input_buff = axiom_data_handler_get_input_stream(data_handler, env); + buff_len = axiom_data_handler_get_input_stream_len(data_handler, env); + + data_handler_res = axiom_data_handler_create(env, NULL, NULL); + + buff = AXIS2_MALLOC(env->allocator, sizeof(axis2_byte_t)*buff_len); + + if (!buff) + { + AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, + "malloc failed, not enough memory"); + return NULL; + } + + memcpy(buff, input_buff, buff_len); + + axiom_data_handler_set_binary_data(data_handler_res, env, buff, buff_len); + + axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE); + ret_node = build_response2(env, data_handler_res); + } + else if(data_handler && axiom_data_handler_get_cached(data_handler, env)) + { + axiom_data_handler_t *data_handler_res = NULL; + axis2_char_t *file_name = NULL; + + file_name = axiom_data_handler_get_file_name(data_handler, env); + if(!file_name) + { + return NULL; + } + + data_handler_res = axiom_data_handler_create(env, file_name, NULL); + + axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE); + ret_node = build_response2(env, data_handler_res); + } + + else if (axiom_node_get_node_type(binary_node, env) == AXIOM_TEXT) /* attachment has come by value, as non-optimized binary */ + { + int plain_binary_len = 0; + int ret_len = 0; + axiom_text_t *bin_text = (axiom_text_t *) + axiom_node_get_data_element(binary_node, env); + axis2_byte_t *plain_binary = NULL; + axiom_data_handler_t *data_handler = NULL; + + axis2_char_t *base64text = + (axis2_char_t *) axiom_text_get_value(bin_text, + env); + printf("base64text = %s\n", base64text); + plain_binary_len = axutil_base64_decode_len(base64text); + plain_binary = AXIS2_MALLOC(env-> + allocator, + sizeof(unsigned char) * + plain_binary_len); + ret_len = + axutil_base64_decode_binary((unsigned char *) + plain_binary, + base64text); + data_handler = + axiom_data_handler_create(env, text_str, NULL); + axiom_data_handler_set_binary_data(data_handler, env, + plain_binary, + ret_len); + axiom_data_handler_write_to(data_handler, env); + ret_node = build_response1(env, base64text); + } + else /* nothing came */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_ATTACHMENT_MISSING, + AXIS2_FAILURE); + printf("Echo client ERROR: attachment is missing.\n"); + return NULL; + } + /* } */ + } + } + + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Echo client ERROR: invalid XML in request\n"); + return NULL; + } + + return ret_node; +} + +/* Builds the response content */ +axiom_node_t * +build_response1( + const axutil_env_t * env, + axis2_char_t * text) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *om_node = NULL; + axiom_element_t *om_ele = NULL; + + + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + + mtom_om_ele = + axiom_element_create(env, NULL, "response", ns1, &mtom_om_node); + + om_ele = axiom_element_create(env, mtom_om_node, "string", NULL, &om_node); + + axiom_element_set_text(mtom_om_ele, env, text, om_node); + + + return mtom_om_node; +} + + +axiom_node_t *build_response2( + const axutil_env_t *env, + axiom_data_handler_t *data_handler) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *text_node = NULL; + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "response", ns1, &mtom_om_node); + + axiom_text_create_with_data_handler(env, mtom_om_node, data_handler, + &text_node); + + return mtom_om_node; +} + + + diff --git a/samples/server/mtom/mtom.h b/samples/server/mtom/mtom.h new file mode 100644 index 0000000..8ee6a39 --- /dev/null +++ b/samples/server/mtom/mtom.h @@ -0,0 +1,33 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CALC_H +#define CALC_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_mtom_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx); + +#endif /* CALC_H */ diff --git a/samples/server/mtom/mtom.mk b/samples/server/mtom/mtom.mk new file mode 100644 index 0000000..a2d9b9b --- /dev/null +++ b/samples/server/mtom/mtom.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:mtom.dll + + + + + diff --git a/samples/server/mtom/mtom_skeleton.c b/samples/server/mtom/mtom_skeleton.c new file mode 100644 index 0000000..3ef10b6 --- /dev/null +++ b/samples/server/mtom/mtom_skeleton.c @@ -0,0 +1,166 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "mtom.h" +#include + +int AXIS2_CALL mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { + mtom_init, + mtom_invoke, + mtom_on_fault, + mtom_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_mtom_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + /* Allocate memory for the structs */ + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &mtom_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of mtom service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only mtom in this sample, hence invoke mtom method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + return axis2_mtom_mtom(env, node, msg_ctx); +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_node_t *text_node = NULL; + axiom_element_t *error_ele = NULL; + error_ele = axiom_element_create(env, node, "EchoServiceError", NULL, + &error_node); + axiom_element_set_text(error_ele, env, "Echo service failed ", text_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_mtom_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/mtom/services.xml b/samples/server/mtom/services.xml new file mode 100644 index 0000000..1a1b1b2 --- /dev/null +++ b/samples/server/mtom/services.xml @@ -0,0 +1,12 @@ + + mtom + + + This is a testing service , to test the system is working or not + + + + http://ws.apache.org/axis2/c/samples/mtom + + + diff --git a/samples/server/mtom_callback/Makefile.am b/samples/server/mtom_callback/Makefile.am new file mode 100644 index 0000000..11a107e --- /dev/null +++ b/samples/server/mtom_callback/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/mtom_callback +prglib_LTLIBRARIES = libmtom_callback.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml mtom_callback.mk mtom_callback.h +noinst_HEADERS = mtom_callback.h +SUBDIRS = +libmtom_callback_la_SOURCES = mtom_callback.c mtom_skeleton.c +libmtom_callback_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/mtom_callback/mtom_callback.c b/samples/server/mtom_callback/mtom_callback.c new file mode 100644 index 0000000..7029124 --- /dev/null +++ b/samples/server/mtom_callback/mtom_callback.c @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "mtom_callback.h" +#include +#include +#include +#include +#include +#include +#include + +axiom_node_t *build_response( + const axutil_env_t *env, + axiom_data_handler_t *data_handler); + +axis2_status_t process_attachments( + axis2_msg_ctx_t *msg_ctx, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name); + +axiom_node_t* +axis2_mtom_callback_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx) +{ + axiom_node_t *attachment_node = NULL; + axiom_node_t *binary_node = NULL; + axiom_node_t *ret_node = NULL; + axis2_status_t status = AXIS2_FAILURE; + void *user_param = NULL; + axutil_param_t *callback_name_param = NULL; + axis2_char_t *callback_name = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + /* Expected request format is :- + * + + + + + */ + if (!node) /* 'mtomSample' node */ + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Echo client ERROR: input parameter NULL\n"); + return NULL; + } + + attachment_node = axiom_node_get_first_child(node, env); + if (!attachment_node) /* 'text' node */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Echo client ERROR: invalid XML in request\n"); + return NULL; + } + + /* This is the paramter specified in the services.xml + * or in axis2.xml + */ + + callback_name_param = axis2_msg_ctx_get_parameter (msg_ctx, env, + AXIS2_MTOM_CACHING_CALLBACK); + + if(callback_name_param) + { + callback_name = (axis2_char_t *) axutil_param_get_value (callback_name_param, env); + } + + /* This will process the attachment data in the stream */ + + status = process_attachments(msg_ctx, env, user_param, callback_name); + if(status == AXIS2_FAILURE) + { + return NULL; + } + + binary_node = axiom_node_get_first_child(attachment_node, env); + if (binary_node) + { + axiom_data_handler_t *data_handler = NULL; + axiom_text_t *bin_text = NULL; + axis2_char_t *attachment_id = NULL; + axiom_data_handler_t *data_handler_res = NULL; + axis2_char_t *location = NULL; + + bin_text = (axiom_text_t *)axiom_node_get_data_element(binary_node, env); + if(bin_text) + { + data_handler = axiom_text_get_data_handler(bin_text, env); + if(!data_handler) + { + return NULL; + } + } + + attachment_id = axiom_data_handler_get_mime_id(data_handler, env); + + if(!attachment_id) + { + return NULL; + } + + /* This is the case where the attachment resides in memory */ + + if (!axiom_data_handler_get_cached(data_handler, env)) + { + /* axis2_byte_t *input_buff = NULL; + axis2_byte_t *buff = NULL; + int buff_len = 0;*/ + + axiom_data_handler_set_file_name(data_handler, env, attachment_id); + axiom_data_handler_write_to(data_handler, env); + location = attachment_id; + } + + else + { + axiom_data_handler_type_t data_handler_type; + data_handler_type = axiom_data_handler_get_data_handler_type(data_handler, env); + + if(data_handler_type == AXIOM_DATA_HANDLER_TYPE_CALLBACK) + { + /* The service implementer should be aware of how to deal with the attachment + * Becasue it was stored using the callback he provided. */ + + /*axis2_char_t command[1000]; + + sprintf(command, "rm -f /opt/tmp/%s", attachment_id); + system(command);*/ + + /*location = attachment_id;*/ + /*location = "/home/manjula/axis2/mtom/resources/song.MP3"; */ + + location = "/opt/manjula-mtom.MPG"; + } + else if(data_handler_type == AXIOM_DATA_HANDLER_TYPE_FILE) + { + axis2_char_t *file_name = NULL; + + file_name = axiom_data_handler_get_file_name(data_handler, env); + if(file_name) + { + location = axutil_strdup(env, file_name); + } + } + } + + /* The samples sends back an attachment to the client. Hence we are creating the + * response data_handler as a type CALLBACK. So the sender callback should be + * specified either in the services.xml or in the axis2.xml. + */ + + data_handler_res = axiom_data_handler_create(env, NULL, NULL); + axiom_data_handler_set_data_handler_type(data_handler_res, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK); + axiom_data_handler_set_user_param(data_handler_res, env, (void *)location); + + axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE); + ret_node = build_response(env, data_handler_res); + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Echo client ERROR: invalid XML in request\n"); + return NULL; + } + + return ret_node; +} + +/* Builds the response content */ + + +axiom_node_t *build_response( + const axutil_env_t *env, + axiom_data_handler_t *data_handler) +{ + axiom_node_t *mtom_om_node = NULL; + axiom_element_t *mtom_om_ele = NULL; + axiom_node_t *text_node = NULL; + axiom_namespace_t *ns1 = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", + "ns1"); + mtom_om_ele = + axiom_element_create(env, NULL, "response", ns1, &mtom_om_node); + + axiom_text_create_with_data_handler(env, mtom_om_node, data_handler, + &text_node); + + return mtom_om_node; +} + +axis2_status_t process_attachments( + axis2_msg_ctx_t *msg_ctx, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name) +{ + axis2_op_ctx_t *op_ctx = NULL; + axis2_msg_ctx_t *in_msg_ctx = NULL; + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + + op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); + if(op_ctx) + { + in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); + if(in_msg_ctx) + { + soap_envelope = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env); + if(soap_envelope) + { + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + if(soap_body) + { + return axiom_soap_body_process_attachments(soap_body, env, user_param, callback_name); + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } +} + diff --git a/samples/server/mtom_callback/mtom_callback.h b/samples/server/mtom_callback/mtom_callback.h new file mode 100644 index 0000000..b7c0057 --- /dev/null +++ b/samples/server/mtom_callback/mtom_callback.h @@ -0,0 +1,33 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MTOM_CALLBACK_H +#define MTOM_CALLBACK_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_mtom_callback_mtom( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t *msg_ctx); + +#endif /* MTOM_CALLBACK_H */ diff --git a/samples/server/mtom_callback/mtom_callback.mk b/samples/server/mtom_callback/mtom_callback.mk new file mode 100644 index 0000000..29cca6a --- /dev/null +++ b/samples/server/mtom_callback/mtom_callback.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:mtom_callback.dll + + + + + diff --git a/samples/server/mtom_callback/mtom_skeleton.c b/samples/server/mtom_callback/mtom_skeleton.c new file mode 100644 index 0000000..941521e --- /dev/null +++ b/samples/server/mtom_callback/mtom_skeleton.c @@ -0,0 +1,166 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "mtom_callback.h" +#include + +int AXIS2_CALL mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { + mtom_init, + mtom_invoke, + mtom_on_fault, + mtom_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_mtom_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + /* Allocate memory for the structs */ + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &mtom_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +mtom_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of mtom service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +mtom_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only mtom in this sample, hence invoke mtom method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + return axis2_mtom_callback_mtom(env, node, msg_ctx); +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +mtom_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_node_t *text_node = NULL; + axiom_element_t *error_ele = NULL; + error_ele = axiom_element_create(env, node, "EchoServiceError", NULL, + &error_node); + axiom_element_set_text(error_ele, env, "Echo service failed ", text_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +mtom_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_mtom_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/mtom_callback/services.xml b/samples/server/mtom_callback/services.xml new file mode 100644 index 0000000..7219c8b --- /dev/null +++ b/samples/server/mtom_callback/services.xml @@ -0,0 +1,16 @@ + + mtom_callback + + + + + + + This is a testing service , to test the system is working or not + + + + http://ws.apache.org/axis2/c/samples/mtomCallbackSample + + + diff --git a/samples/server/notify/Makefile.am b/samples/server/notify/Makefile.am new file mode 100644 index 0000000..2e2bf2c --- /dev/null +++ b/samples/server/notify/Makefile.am @@ -0,0 +1,9 @@ +prglibdir=$(prefix)/services/notify +prglib_LTLIBRARIES = libnotify.la +prglib_DATA= services.xml +EXTRA_DIST = services.xml notify.mk notify.h +noinst_HEADERS = notify.h +SUBDIRS = +libnotify_la_SOURCES = notify.c notify_skeleton.c +libnotify_la_LIBADD = +INCLUDES = @AXIS2INC@ diff --git a/samples/server/notify/notify.c b/samples/server/notify/notify.c new file mode 100644 index 0000000..80dc5bd --- /dev/null +++ b/samples/server/notify/notify.c @@ -0,0 +1,77 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "notify.h" +#include + +void +axis2_notify_notify( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *text_node = NULL; + + if (!env || !env) + { + return; + } + + /* Expected request format is :- + Message 3 + */ + if (!node) /* 'notify' node */ + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: input parameter NULL"); + return; + } + + text_node = axiom_node_get_first_child(node, env); + if (!text_node) /* actual text to notify */ + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: invalid XML in request"); + return; + } + + if (axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(text_node, env); + if (text && axiom_text_get_value(text, env)) + { + axis2_char_t *text_str = + (axis2_char_t *) axiom_text_get_value(text, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Notification received : %s", text_str); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: invalid XML in request"); + return; + } + + return; +} + diff --git a/samples/server/notify/notify.h b/samples/server/notify/notify.h new file mode 100644 index 0000000..5a175a0 --- /dev/null +++ b/samples/server/notify/notify.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CALC_H +#define CALC_H + +#include +#include +#include +#include +#include +#include + +void axis2_notify_notify( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* CALC_H */ diff --git a/samples/server/notify/notify.mk b/samples/server/notify/notify.mk new file mode 100644 index 0000000..9f3d533 --- /dev/null +++ b/samples/server/notify/notify.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c + @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:notify.dll + + + + + diff --git a/samples/server/notify/notify_skeleton.c b/samples/server/notify/notify_skeleton.c new file mode 100644 index 0000000..82acf49 --- /dev/null +++ b/samples/server/notify/notify_skeleton.c @@ -0,0 +1,167 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "notify.h" +#include + +int AXIS2_CALL notify_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL notify_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL notify_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +axiom_node_t *AXIS2_CALL notify_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node); + +static const axis2_svc_skeleton_ops_t notify_svc_skeleton_ops_var = { + notify_init, + notify_invoke, + notify_on_fault, + notify_free +}; + +/*Create function */ +axis2_svc_skeleton_t * +axis2_notify_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + /* Allocate memory for the structs */ + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = ¬ify_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +/* Initialize the service */ +int AXIS2_CALL +notify_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of notify service should go here */ + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +notify_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Invoke the business logic. + * Depending on the function name invoke the correct impl method. + * We have only notify in this sample, hence invoke notify method. + * To see how to deal with multiple impl methods, have a look at the + * math sample. + */ + axis2_notify_notify(env, node); + return NULL; +} + +/* On fault, handle the fault */ +axiom_node_t *AXIS2_CALL +notify_on_fault( + axis2_svc_skeleton_t * svc_skeli, + const axutil_env_t * env, + axiom_node_t * node) +{ + /* Here we are just setting a simple error message inside an element + * called 'EchoServiceError' + */ + axiom_node_t *error_node = NULL; + axiom_node_t *text_node = NULL; + axiom_element_t *error_ele = NULL; + error_ele = axiom_element_create(env, node, "NotifyServiceError", NULL, + &error_node); + axiom_element_set_text(error_ele, env, "Notify service failed ", text_node); + return error_node; +} + +/* Free the resources used */ +int AXIS2_CALL +notify_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Free the function array */ + if (svc_skeleton->func_array) + { + axutil_array_list_free(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + } + + /* Free the service skeleton */ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ +AXIS2_EXPORT int +axis2_get_instance( + axis2_svc_skeleton_t ** inst, + const axutil_env_t * env) +{ + *inst = axis2_notify_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/notify/services.xml b/samples/server/notify/services.xml new file mode 100644 index 0000000..ff2be47 --- /dev/null +++ b/samples/server/notify/services.xml @@ -0,0 +1,13 @@ + + notify + + + This is a testing service , to test one way service support + + + + + http://example.org/action/notify + + + diff --git a/samples/server/sg_math/Makefile.am b/samples/server/sg_math/Makefile.am new file mode 100644 index 0000000..82cc1ba --- /dev/null +++ b/samples/server/sg_math/Makefile.am @@ -0,0 +1,11 @@ +prglibdir=$(prefix)/services/sg_math +prglib_LTLIBRARIES = libadd.la libsub.la libmul.la libdiv.la +prglib_DATA=services.xml +EXTRA_DIST = services.xml sg_math.mk add.h div.h mul.h sub.h + +noinst_HEADERS = add.h sub.h mul.h div.h +libadd_la_SOURCES = add.c add_skeleton.c +libsub_la_SOURCES = sub.c sub_skeleton.c +libmul_la_SOURCES = mul.c mul_skeleton.c +libdiv_la_SOURCES = div.c div_skeleton.c +INCLUDES = @AXIS2INC@ diff --git a/samples/server/sg_math/add.c b/samples/server/sg_math/add.c new file mode 100644 index 0000000..91cf99a --- /dev/null +++ b/samples/server/sg_math/add.c @@ -0,0 +1,180 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "add.h" +#include +#include + +axiom_node_t * +axis2_add_add( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + axis2_svc_grp_ctx_t *svc_grp_ctx = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 + param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + /* Put the result into service group context */ + svc_grp_ctx = axis2_msg_ctx_get_svc_grp_ctx(msg_ctx, env); + if (svc_grp_ctx) + { + axis2_ctx_t *ctx = NULL; + ctx = axis2_svc_grp_ctx_get_base(svc_grp_ctx, env); + if (ctx) + { + axutil_property_t *prop = NULL; + /* get value */ + prop = axis2_ctx_get_property(ctx, env, "ADD_RESULT"); + if (prop) + { + axis2_char_t *val = + (axis2_char_t *) axutil_property_get_value(prop, env); + printf("Previous result = %s\n", val); + } + /* set value */ + prop = axutil_property_create(env); + if (prop) + { + axutil_property_set_value(prop, env, + axutil_strdup(env, result_str)); + axis2_ctx_set_property(ctx, env, "ADD_RESULT", prop); + } + } + } + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/add.h b/samples/server/sg_math/add.h new file mode 100644 index 0000000..40ec76b --- /dev/null +++ b/samples/server/sg_math/add.h @@ -0,0 +1,33 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ADD_H +#define ADD_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_add_add( + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +#endif /* ADD_H */ diff --git a/samples/server/sg_math/add_skeleton.c b/samples/server/sg_math/add_skeleton.c new file mode 100644 index 0000000..7e7e13a --- /dev/null +++ b/samples/server/sg_math/add_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "add.h" +#include +#include + +int AXIS2_CALL add_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL add_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL add_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t add_svc_skeleton_ops_var = { + add_init, + add_invoke, + NULL, + add_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_add_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &add_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +add_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of add goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +add_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +add_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding add method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "add") == 0) + return axis2_add_add(env, node, msg_ctx); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = axis2_add_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/sg_math/div.c b/samples/server/sg_math/div.c new file mode 100644 index 0000000..13ac9b5 --- /dev/null +++ b/samples/server/sg_math/div.c @@ -0,0 +1,150 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "div.h" +#include + +axiom_node_t * +axis2_div_div( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + if (param2 == 0) + return NULL; + result = param1 / param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/div.h b/samples/server/sg_math/div.h new file mode 100644 index 0000000..3b03e42 --- /dev/null +++ b/samples/server/sg_math/div.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef DIV_H +#define DIV_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_div_div( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* DIV_H */ diff --git a/samples/server/sg_math/div_skeleton.c b/samples/server/sg_math/div_skeleton.c new file mode 100644 index 0000000..9007a58 --- /dev/null +++ b/samples/server/sg_math/div_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "div.h" +#include +#include + +int AXIS2_CALL div_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL div_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL div_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t div_svc_skeleton_ops_var = { + div_init, + div_invoke, + NULL, + div_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_div_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &div_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +div_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of div goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +div_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +div_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding div method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "div") == 0) + return axis2_div_div(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = axis2_div_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/sg_math/mul.c b/samples/server/sg_math/mul.c new file mode 100644 index 0000000..b86a22b --- /dev/null +++ b/samples/server/sg_math/mul.c @@ -0,0 +1,148 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "mul.h" +#include + +axiom_node_t * +axis2_mul_mul( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 * param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/mul.h b/samples/server/sg_math/mul.h new file mode 100644 index 0000000..5e2d243 --- /dev/null +++ b/samples/server/sg_math/mul.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MUL_H +#define MUL_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_mul_mul( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* MUL_H */ diff --git a/samples/server/sg_math/mul_skeleton.c b/samples/server/sg_math/mul_skeleton.c new file mode 100644 index 0000000..1a58e3b --- /dev/null +++ b/samples/server/sg_math/mul_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "mul.h" +#include +#include + +int AXIS2_CALL mul_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL mul_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL mul_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t mul_svc_skeleton_ops_var = { + mul_init, + mul_invoke, + NULL, + mul_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_mul_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &mul_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +mul_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of mul goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +mul_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +mul_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding mul method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "mul") == 0) + return axis2_mul_mul(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = axis2_mul_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/sg_math/services.xml b/samples/server/sg_math/services.xml new file mode 100644 index 0000000..524a7ee --- /dev/null +++ b/samples/server/sg_math/services.xml @@ -0,0 +1,30 @@ + + + add + + This is add service, that belongs to the math service group. + + + + + sub + + This is sub service, that belongs to the math service group. + + + + + mul + + This is mul service, that belongs to the math service group. + + + + + div + + This is div service, that belongs to the math service group. + + + + diff --git a/samples/server/sg_math/sg_math.mk b/samples/server/sg_math/sg_math.mk new file mode 100644 index 0000000..5ee16ed --- /dev/null +++ b/samples/server/sg_math/sg_math.mk @@ -0,0 +1,15 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" add.c add_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo add.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:add.dll + + + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" div.c div_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo div.obj /LIBPATH:.\..\..\..\lib axiom.lib axis2_util.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:div.dll + + + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" sub.c sub_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo sub.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:sub.dll + + + @cl.exe /nologo /D "WIN32" /D "AXIS2_DECLARE_EXPORT" /D "_WINDOWS" /D "_MBCS" mul.c mul_skeleton.c /I.\..\..\..\include /c + @link.exe /nologo mul.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:mul.dll diff --git a/samples/server/sg_math/sub.c b/samples/server/sg_math/sub.c new file mode 100644 index 0000000..2b6b4e9 --- /dev/null +++ b/samples/server/sg_math/sub.c @@ -0,0 +1,148 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "sub.h" +#include + +axiom_node_t * +axis2_sub_sub( + const axutil_env_t * env, + axiom_node_t * node) +{ + axiom_node_t *param1_node = NULL; + axiom_node_t *param1_text_node = NULL; + axis2_char_t *param1_str = NULL; + long int param1 = 0; + axiom_node_t *param2_node = NULL; + axiom_node_t *param2_text_node = NULL; + axis2_char_t *param2_str = NULL; + long int param2 = 0; + + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + + param1_node = axiom_node_get_first_child(node, env); + if (!param1_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param1_text_node = axiom_node_get_first_child(param1_node, env); + if (!param1_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param1_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param1_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param1_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_node = axiom_node_get_next_sibling(param1_node, env); + if (!param2_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + param2_text_node = axiom_node_get_first_child(param2_node, env); + if (!param2_text_node) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (axiom_node_get_node_type(param2_text_node, env) == AXIOM_TEXT) + { + axiom_text_t *text = + (axiom_text_t *) axiom_node_get_data_element(param2_text_node, env); + if (text && axiom_text_get_value(text, env)) + { + param2_str = (axis2_char_t *) axiom_text_get_value(text, env); + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid XML in request\n"); + return NULL; + } + + if (param1_str && param2_str) + { + long int result = 0; + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + param1 = strtol(param1_str, NULL, 10); + param2 = strtol(param2_str, NULL, 10); + result = param1 - param2; + sprintf(result_str, "%ld", result); + + ns1 = axiom_namespace_create(env, + "http://axis2/test/namespace1", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} diff --git a/samples/server/sg_math/sub.h b/samples/server/sg_math/sub.h new file mode 100644 index 0000000..9083c57 --- /dev/null +++ b/samples/server/sg_math/sub.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef SUB_H +#define SUB_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_sub_sub( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* SUB_H */ diff --git a/samples/server/sg_math/sub_skeleton.c b/samples/server/sg_math/sub_skeleton.c new file mode 100644 index 0000000..aedeac7 --- /dev/null +++ b/samples/server/sg_math/sub_skeleton.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "sub.h" +#include +#include + +int AXIS2_CALL sub_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL sub_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL sub_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t sub_svc_skeleton_ops_var = { + sub_init, + sub_invoke, + NULL, + sub_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +axis2_sub_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &sub_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +sub_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of sub goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +sub_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +sub_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding sub method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "sub") == 0) + return axis2_sub_sub(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = axis2_sub_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/server/version/Makefile.am b/samples/server/version/Makefile.am new file mode 100644 index 0000000..9e6f94a --- /dev/null +++ b/samples/server/version/Makefile.am @@ -0,0 +1,10 @@ +prglibdir=$(prefix)/services/version +prglib_LTLIBRARIES = libversion.la +prglib_DATA=services.xml +noinst_HEADERS = version.h +SUBDIRS = +libversion_la_SOURCES = version.c version_skel.c +libversion_la_LIBADD = +INCLUDES = @AXIS2INC@ +EXTRA_DIST = services.xml version.h + diff --git a/samples/server/version/services.xml b/samples/server/version/services.xml new file mode 100644 index 0000000..37bdc6b --- /dev/null +++ b/samples/server/version/services.xml @@ -0,0 +1,9 @@ + + version + + This is a testing service, named 'version' to test multiple operations in the same service + + + + + diff --git a/samples/server/version/version.c b/samples/server/version/version.c new file mode 100644 index 0000000..81182eb --- /dev/null +++ b/samples/server/version/version.c @@ -0,0 +1,59 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "version.h" +#include + +axiom_node_t * +axis2_version_get_version( + const axutil_env_t * env, + axiom_node_t * node) +{ + if (!node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, + AXIS2_FAILURE); + printf("Math client request ERROR: input parameter NULL\n"); + return NULL; + } + else + { + axis2_char_t result_str[255]; + + axiom_element_t *ele1 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_namespace_t *ns1 = NULL; + axiom_text_t *text1 = NULL; + + sprintf(result_str, "%s", "Version 1.6"); + + ns1 = axiom_namespace_create(env, + "urn:aewebservices71", "ns1"); + ele1 = axiom_element_create(env, NULL, "result", ns1, &node1); + text1 = axiom_text_create(env, node1, result_str, &node2); + + return node1; + } + + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST, + AXIS2_FAILURE); + printf("Math service ERROR: invalid parameters\n"); + return NULL; +} + diff --git a/samples/server/version/version.h b/samples/server/version/version.h new file mode 100644 index 0000000..56fc54e --- /dev/null +++ b/samples/server/version/version.h @@ -0,0 +1,32 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MATH_H +#define MATH_H + +#include +#include +#include +#include +#include +#include + +axiom_node_t *axis2_version_get_version( + const axutil_env_t * env, + axiom_node_t * node); + +#endif /* MATH_H */ diff --git a/samples/server/version/version_skel.c b/samples/server/version/version_skel.c new file mode 100644 index 0000000..961c3d8 --- /dev/null +++ b/samples/server/version/version_skel.c @@ -0,0 +1,151 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "axis2_svc_skeleton.h" +#include "version.h" +#include +#include + +int AXIS2_CALL version_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL version_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx); + +int AXIS2_CALL version_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env); + +static const axis2_svc_skeleton_ops_t version_svc_skeleton_ops_var = { + version_init, + version_invoke, + NULL, + version_free +}; + +AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL +version_create( + const axutil_env_t * env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t)); + + svc_skeleton->ops = &version_svc_skeleton_ops_var; + + svc_skeleton->func_array = NULL; + + return svc_skeleton; +} + +int AXIS2_CALL +version_init( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + /* Any initialization stuff of version goes here */ + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +version_free( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env) +{ + if (svc_skeleton) + { + AXIS2_FREE(env->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t *AXIS2_CALL +version_invoke( + axis2_svc_skeleton_t * svc_skeleton, + const axutil_env_t * env, + axiom_node_t * node, + axis2_msg_ctx_t * msg_ctx) +{ + /* Depending on the function name invoke the + * corresponding version method + */ + if (node) + { + if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = + (axiom_element_t *) axiom_node_get_data_element(node, env); + if (element) + { + axis2_char_t *op_name = + axiom_element_get_localname(element, env); + if (op_name) + { + if (axutil_strcmp(op_name, "GetVersion") == 0) + return axis2_version_get_version(env, node); + } + } + } + } + + printf("Math service ERROR: invalid OM parameters in request\n"); + + /** Note: return a SOAP fault here */ + return node; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance( + struct axis2_svc_skeleton **inst, + const axutil_env_t * env) +{ + *inst = version_create(env); + if (!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance( + axis2_svc_skeleton_t * inst, + const axutil_env_t * env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} diff --git a/samples/user_guide/Makefile.am b/samples/user_guide/Makefile.am new file mode 100644 index 0000000..fc8e098 --- /dev/null +++ b/samples/user_guide/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = clients diff --git a/samples/user_guide/clients/Makefile.am b/samples/user_guide/clients/Makefile.am new file mode 100644 index 0000000..91da51d --- /dev/null +++ b/samples/user_guide/clients/Makefile.am @@ -0,0 +1,37 @@ +prgbindir=$(prefix)/samples/bin +prgbin_PROGRAMS = echo_blocking echo_non_blocking echo_blocking_addr echo_rest echo_blocking_dual echo_non_blocking_dual echo_blocking_soap11 echo_blocking_auth + + +echo_blocking_SOURCES = echo_blocking.c echo_util.c +echo_non_blocking_SOURCES = echo_non_blocking.c echo_util.c +echo_blocking_addr_SOURCES = echo_blocking_addr.c echo_util.c +echo_rest_SOURCES = echo_util.c echo_rest.c +echo_blocking_dual_SOURCES = echo_blocking_dual.c echo_util.c +echo_non_blocking_dual_SOURCES = echo_non_blocking_dual.c echo_util.c +echo_blocking_soap11_SOURCES = echo_blocking_soap11.c echo_util.c +echo_blocking_auth_SOURCES = echo_blocking_auth.c echo_util.c + +LINK_FLAGS = $(LDFLAGS) \ + -L$(AXIS2C_HOME)/lib \ + -laxutil \ + -laxis2_axiom \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + $(GUTHTHILA_LIBS) + +echo_blocking_LDADD = $(LINK_FLAGS) +echo_non_blocking_LDADD = $(LINK_FLAGS) +echo_blocking_addr_LDADD = $(LINK_FLAGS) +echo_rest_LDADD = $(LINK_FLAGS) +echo_blocking_dual_LDADD = $(LINK_FLAGS) +echo_non_blocking_dual_LDADD = $(LINK_FLAGS) +echo_blocking_soap11_LDADD = $(LINK_FLAGS) +echo_blocking_auth_LDADD = $(LINK_FLAGS) + +INCLUDES = @AXIS2INC@ + +EXTRA_DIST=echo_util.h echo_blocking_addr.mk echo_blocking.mk echo_non_blocking_dual.mk echo_rest.mk echo_blocking_dual.mk echo_blocking_soap11.mk echo_non_blocking.mk echo_blocking_auth.mk + diff --git a/samples/user_guide/clients/echo_blocking.c b/samples/user_guide/clients/echo_blocking.c new file mode 100644 index 0000000..4657814 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking.c @@ -0,0 +1,126 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + + /* Set up the environment */ + env = axutil_env_create_all("echo_blocking.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/user_guide/clients/echo_blocking.mk b/samples/user_guide/clients/echo_blocking.mk new file mode 100644 index 0000000..362a458 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_blocking.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_blocking.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_blocking.exe + + + + + diff --git a/samples/user_guide/clients/echo_blocking_addr.c b/samples/user_guide/clients/echo_blocking_addr.c new file mode 100644 index 0000000..20cc6eb --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_addr.c @@ -0,0 +1,132 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_blocking_addr.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/user_guide/clients/echo_blocking_addr.mk b/samples/user_guide/clients/echo_blocking_addr.mk new file mode 100644 index 0000000..88b519f --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_addr.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_blocking_addr.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_blocking_addr.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_blocking_addr.exe + + + + + diff --git a/samples/user_guide/clients/echo_blocking_auth.c b/samples/user_guide/clients/echo_blocking_auth.c new file mode 100644 index 0000000..375dbd0 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_auth.c @@ -0,0 +1,295 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + +axiom_node_t *build_om_payload_for_echo_svc( + const axutil_env_t * env); + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + const axis2_char_t *un = NULL; + const axis2_char_t *pw = NULL; + const axis2_char_t *unp = NULL; + const axis2_char_t *pwp = NULL; + axis2_bool_t http_auth_required = AXIS2_FALSE; + axis2_bool_t proxy_auth_required = AXIS2_FALSE; + + /* Set up the environment */ + env = axutil_env_create_all("echo_blocking_auth.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + { + if (axutil_strcmp(argv[1], "-h") == 0) + { + printf("Usage : %s [endpoint_url] (-a [username] [password]) (-p [username] [password])\n", + argv[0]); + printf("use -a option for HTTP Authentication\n"); + printf("use -p option for Proxy Authentication\n"); + printf("use -h for help\n"); + return 0; + } + else if (axutil_strcmp(argv[1], "-a") == 0) + { + if (argc > 3) + { + un = argv[2]; + pw = argv[3]; + } + } + else if (axutil_strcmp(argv[1], "-p") == 0) + { + if (argc > 3) + { + unp = argv[2]; + pwp = argv[3]; + } + } + else + { + address = argv[1]; + } + + if (argc > 4) + { + if (axutil_strcmp(argv[2], "-a") == 0) + { + un = argv[3]; + pw = argv[4]; + } + else if (axutil_strcmp(argv[2], "-p") == 0) + { + unp = argv[3]; + pwp = argv[4]; + } + } + if (argc > 6) + { + if (axutil_strcmp(argv[4], "-a") == 0) + { + un = argv[5]; + pw = argv[6]; + if (argc > 7) + { + address = argv[7]; + } + } + else if (axutil_strcmp(argv[4], "-p") == 0) + { + unp = argv[5]; + pwp = argv[6]; + if (argc > 7) + { + address = argv[7]; + } + } + } + if (argc > 7) + { + if (axutil_strcmp(argv[5], "-a") == 0) + { + un = argv[6]; + pw = argv[7]; + if (!address) + { + address = argv[4]; + } + } + else if (axutil_strcmp(argv[5], "-p") == 0) + { + unp = argv[6]; + pwp = argv[7]; + if (!address) + { + address = argv[4]; + } + } + } + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Enabling REST for HTTP HEAD Request */ + axis2_options_set_enable_rest(options, env, AXIS2_TRUE); + + /* Setting Request as HTTP HEAD Request */ + axis2_options_set_http_method(options, env, AXIS2_HTTP_HEAD); + + /* Sending dummy authentication info */ + if (un && pw) + { + axis2_options_set_http_auth_info(options, env, "", "", NULL); + } + if (unp && pwp) + { + axis2_options_set_proxy_auth_info(options, env, "", "", NULL); + } + + /* Force authentication tests */ + axis2_options_set_test_http_auth(options, env, AXIS2_TRUE); + axis2_options_set_test_proxy_auth(options, env, AXIS2_TRUE); + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* un-comment line below to setup proxy from code*/ + /*axis2_svc_client_set_proxy_with_auth(svc_client, env, "127.0.0.1", "3128", NULL, NULL);*/ + + /* Sending robust authentication test message */ + axis2_svc_client_send_robust(svc_client, env, NULL); + + /* Checking whether authentication is required */ + if (axis2_svc_client_get_proxy_auth_required(svc_client, env)) + { + proxy_auth_required = AXIS2_TRUE; + + /* Set proxy-auth information */ + if (unp && pwp) + { + axis2_options_set_proxy_auth_info(options, env, unp, pwp, + axis2_svc_client_get_auth_type(svc_client, env)); + /* un-comment line below to setup proxy from code*/ + /*axis2_svc_client_set_proxy_with_auth(svc_client, env, "127.0.0.1", "3128", unp, pwp);*/ + } + + /* Sending robust authentication test message */ + axis2_svc_client_send_robust(svc_client, env, NULL); + } + if (axis2_svc_client_get_http_auth_required(svc_client, env)) + { + http_auth_required = AXIS2_TRUE; + /* Set http-auth information */ + if (un && pw) + { + axis2_options_set_http_auth_info(options, env, un, pw, + axis2_svc_client_get_auth_type(svc_client, env)); + } + } + + /* Cancel authentication tests */ + axis2_options_set_test_http_auth(options, env, AXIS2_FALSE); + axis2_options_set_test_proxy_auth(options, env, AXIS2_FALSE); + + /* Print whether authentication was required */ + if (http_auth_required) + { + printf("\nHTTP Authentication info required.\n"); + } + if (proxy_auth_required) + { + printf("\nProxy Authentication info required.\n"); + } + + /* Disabling REST for SOAP Request */ + axis2_options_set_enable_rest(options, env, AXIS2_FALSE); + + /* Setting Request as HTTP POST Request */ + axis2_options_set_http_method(options, env, AXIS2_HTTP_POST); + + /* Engage addressing module */ + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + printf("\nReceived OM : %s\n", om_str); + printf("\necho client invoke SUCCESSFUL!\n"); + + AXIS2_FREE(env->allocator, om_str); + ret_node = NULL; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/user_guide/clients/echo_blocking_auth.mk b/samples/user_guide/clients/echo_blocking_auth.mk new file mode 100644 index 0000000..b6c74fe --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_auth.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_blocking_auth.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_blocking_auth.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_blocking_auth.exe + + + + + diff --git a/samples/user_guide/clients/echo_blocking_dual.c b/samples/user_guide/clients/echo_blocking_dual.c new file mode 100644 index 0000000..9d25637 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_dual.c @@ -0,0 +1,140 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_endpoint_ref_t *reply_to = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_blocking_dual.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE); + + /* Seperate listner needs addressing, hence addressing stuff in options */ + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + reply_to = + axis2_endpoint_ref_create(env, + "http://localhost:6060/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__"); + axis2_options_set_reply_to(options, env, reply_to); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + AXIS2_SLEEP(1); + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/user_guide/clients/echo_blocking_dual.mk b/samples/user_guide/clients/echo_blocking_dual.mk new file mode 100644 index 0000000..89fe2d7 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_dual.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_blocking_dual.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_blocking_dual.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_blocking_dual.exe + + + + + diff --git a/samples/user_guide/clients/echo_blocking_soap11.c b/samples/user_guide/clients/echo_blocking_soap11.c new file mode 100644 index 0000000..104dc55 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_soap11.c @@ -0,0 +1,135 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + axutil_string_t *soap_action = NULL; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_blocking_soap11.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_soap_version(options, env, AXIOM_SOAP11); + soap_action = + axutil_string_create(env, + "http://ws.apache.org/axis2/c/samples/echo/soap_action"); + axis2_options_set_soap_action(options, env, soap_action); + axutil_string_free(soap_action, env); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} diff --git a/samples/user_guide/clients/echo_blocking_soap11.mk b/samples/user_guide/clients/echo_blocking_soap11.mk new file mode 100644 index 0000000..eebd7e2 --- /dev/null +++ b/samples/user_guide/clients/echo_blocking_soap11.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_blocking_soap11.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_blocking_soap11.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_blocking_soap11.exe + + + + + diff --git a/samples/user_guide/clients/echo_non_blocking.c b/samples/user_guide/clients/echo_non_blocking.c new file mode 100644 index 0000000..22cdbb8 --- /dev/null +++ b/samples/user_guide/clients/echo_non_blocking.c @@ -0,0 +1,211 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +/* my on_complete callback function */ +axis2_status_t AXIS2_CALL echo_process_response_envelope( + struct axis2_callback * callback, + const axutil_env_t * env); + +/* my on_error callback function */ +axis2_status_t AXIS2_CALL echo_callback_on_error( + struct axis2_callback *callback, + const axutil_env_t * env, + int exception); + +/* to check whether the callback is completed */ + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axis2_callback_t *callback = NULL; + int count = 0; + + /* Set up the environment */ + env = axutil_env_create_all("echo_non_blocking.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Create the callback object with default on_complete and on_error + callback functions */ + callback = axis2_callback_create(env); + + /* Set our on_complete fucntion pointer to the callback object */ + /*axis2_callback_set_on_complete(callback, echo_callback_on_complete);*/ + + /* Set our on_error function pointer to the callback object */ + axis2_callback_set_on_error(callback, echo_callback_on_error); + + /* Send request */ + axis2_svc_client_send_receive_non_blocking(svc_client, env, + payload, callback); + + /** Wait till callback is complete. Simply keep the parent thread running + until our on_complete or on_error is invoked */ + + while(!axis2_callback_get_complete(callback, env)) + { + AXIS2_SLEEP(1); + if(count < 30) + { + count++; + } + else + { + printf("\necho client invoke FAILED. Counter timed out.\n"); + } + + } + echo_process_response_envelope(callback, env); + if(svc_client) + axis2_svc_client_free(svc_client, env); + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +axis2_status_t AXIS2_CALL +echo_process_response_envelope( + struct axis2_callback * callback, + const axutil_env_t * env) +{ + + /** SOAP response has arrived here; get the soap envelope + from the callback object and do whatever you want to do with it */ + + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_node_t *ret_node = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + soap_envelope = axis2_callback_get_envelope(callback, env); + + if (!soap_envelope) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env); + + if (!ret_node) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + } + + return status; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_error( + struct axis2_callback * callback, + const axutil_env_t * env, + int exception) +{ + + /** take necessary action on error */ + printf("\necho client invike FAILED. Error code:%d ::%s", exception, + AXIS2_ERROR_GET_MESSAGE(env->error)); + + return AXIS2_SUCCESS; +} diff --git a/samples/user_guide/clients/echo_non_blocking.mk b/samples/user_guide/clients/echo_non_blocking.mk new file mode 100644 index 0000000..efb6550 --- /dev/null +++ b/samples/user_guide/clients/echo_non_blocking.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_non_blocking.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_non_blocking.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_non_blocking.exe + + + + + diff --git a/samples/user_guide/clients/echo_non_blocking_dual.c b/samples/user_guide/clients/echo_non_blocking_dual.c new file mode 100644 index 0000000..60d20ae --- /dev/null +++ b/samples/user_guide/clients/echo_non_blocking_dual.c @@ -0,0 +1,233 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include + +#define MAX_COUNT 3000000 + +/* my on_complete callback function */ +axis2_status_t AXIS2_CALL echo_callback_on_complete( + struct axis2_callback * callback, + const axutil_env_t * env); + +/* my on_error callback function */ +axis2_status_t AXIS2_CALL echo_callback_on_error( + struct axis2_callback *callback, + const axutil_env_t * env, + int exception); + +/* to check whether the callback is completed */ +int isComplete = 0; + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_endpoint_ref_t *reply_to = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axis2_callback_t *callback = NULL; + int count = 0; + + /* Set up the environment */ + env = + axutil_env_create_all("echo_non_blocking_dual.log", + AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo"; + if (argc > 1) + address = argv[1]; + if (axutil_strcmp(address, "-h") == 0) + { + printf("Usage : %s [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + return 0; + } + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE); + + /* Seperate listner needs addressing, hence addressing stuff in options */ + axis2_options_set_action(options, env, + "http://ws.apache.org/axis2/c/samples/echoString"); + reply_to = + axis2_endpoint_ref_create(env, + "http://localhost:6060/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__"); + axis2_options_set_reply_to(options, env, reply_to); + + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); + /*axis2_svc_client_engage_module(svc_client, env, "sandesha2"); */ + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Create the callback object with default on_complete and on_error + callback functions */ + callback = axis2_callback_create(env); + + /* Set our on_complete fucntion pointer to the callback object */ + axis2_callback_set_on_complete(callback, echo_callback_on_complete); + + /* Set our on_error function pointer to the callback object */ + axis2_callback_set_on_error(callback, echo_callback_on_error); + + /* Send request */ + axis2_svc_client_send_receive_non_blocking(svc_client, env, + payload, callback); + + /** Wait till callback is complete. Simply keep the parent thread running + until our on_complete or on_error is invoked */ + while (count < MAX_COUNT) + { + if (isComplete) + { + /* We are done with the callback */ + break; + } + +/* AXIS2_SLEEP(1); */ + count++; + } + + if (!(count < MAX_COUNT)) + { + printf("\necho client invoke FAILED. Counter timed out.\n"); + } + + if (svc_client) + { + AXIS2_SLEEP(1); + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + + return 0; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_complete( + struct axis2_callback * callback, + const axutil_env_t * env) +{ + + /** SOAP response has arrived here; get the soap envelope + from the callback object and do whatever you want to do with it */ + + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_node_t *ret_node = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + soap_envelope = axis2_callback_get_envelope(callback, env); + + if (!soap_envelope) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env); + + if (!ret_node) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo stub invoke FAILED!\n"); + status = AXIS2_FAILURE; + } + else + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + printf("\nReceived OM : %s\n", om_str); + printf("\necho client invoke SUCCESSFUL!\n"); + } + } + isComplete = 1; + return status; +} + +axis2_status_t AXIS2_CALL +echo_callback_on_error( + struct axis2_callback * callback, + const axutil_env_t * env, + int exception) +{ + + /** take necessary action on error */ + printf("\nEcho client invoke FAILED. Error code:%d ::%s", exception, + AXIS2_ERROR_GET_MESSAGE(env->error)); + isComplete = 1; + return AXIS2_SUCCESS; +} diff --git a/samples/user_guide/clients/echo_non_blocking_dual.mk b/samples/user_guide/clients/echo_non_blocking_dual.mk new file mode 100644 index 0000000..cf9dc95 --- /dev/null +++ b/samples/user_guide/clients/echo_non_blocking_dual.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_non_blocking_dual.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_non_blocking_dual.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_non_blocking_dual.exe + + + + + diff --git a/samples/user_guide/clients/echo_rest.c b/samples/user_guide/clients/echo_rest.c new file mode 100644 index 0000000..6f05e8d --- /dev/null +++ b/samples/user_guide/clients/echo_rest.c @@ -0,0 +1,229 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" +#include +#include +#include +#include + +int +main( + int argc, + char **argv) +{ + const axutil_env_t *env = NULL; + const axis2_char_t *address = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_options_t *options = NULL; + const axis2_char_t *client_home = NULL; + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *payload = NULL; + axiom_node_t *ret_node = NULL; + axis2_bool_t method_get = AXIS2_FALSE; + axis2_bool_t method_head = AXIS2_FALSE; + axis2_bool_t method_put = AXIS2_FALSE; + axis2_bool_t method_delete = AXIS2_FALSE; + + /* Set up the environment */ + env = axutil_env_create_all("echo_rest.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set end point reference of echo service */ + address = "http://localhost:9090/axis2/services/echo/echoString"; + if (argc > 1) + { + if (0 == strncmp(argv[1], "-mGET", 5)) + { + method_get = AXIS2_TRUE; + } + else if (0 == strncmp(argv[1], "-mHEAD", 6)) + { + method_head = AXIS2_TRUE; + } + else if (0 == strncmp(argv[1], "-mPUT", 5)) + { + method_put = AXIS2_TRUE; + } + else if (0 == strncmp(argv[1], "-mDELETE",8 )) + { + method_delete = AXIS2_TRUE; + } + else if (0 == axutil_strcmp(argv[1], "-h")) + { + printf("Usage : %s [endpoint_url] \n", argv[0]); + printf("\nNOTE: You can test for other HTTP methods by changing the"); + printf(" services.xml of the echo service\n and providing the correct REST HTTP method"); + printf(" and the location to be used for operation.\n"); + printf(" Also note that you have to restart the server after changing the services.xml.\n"); + printf(" use %s -mGET for HTTP GET\n", argv[0]); + printf(" use %s -mHEAD for HTTP HEAD\n", argv[0]); + printf(" use %s -mDELETE for HTTP DELETE\n", argv[0]); + printf(" use %s -mPUT for HTTP PUT\n", argv[0]); + printf(" use -h for help\n"); + return 0; + } + else + { + address = argv[1]; + } + } + + if (argc > 2) + { + if (0 == strncmp(argv[2], "-mGET", 5)) + { + method_get = AXIS2_TRUE; + } + else if (0 == strncmp(argv[2], "-mHEAD", 6)) + { + method_head = AXIS2_TRUE; + } + else if (0 == strncmp(argv[2], "-mPUT", 5)) + { + method_put = AXIS2_TRUE; + } + else if (0 == strncmp(argv[2], "-mDELETE",8 )) + { + method_delete = AXIS2_TRUE; + } + else + { + address = argv[2]; + } + } + + printf("Using endpoint : %s\n", address); + + /* Create EPR with given address */ + endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + options = axis2_options_create(env); + axis2_options_set_to(options, env, endpoint_ref); + /* Enable REST at the client side */ + axis2_options_set_enable_rest(options, env, AXIS2_TRUE); + + if (AXIS2_TRUE == method_get) + { + axis2_options_set_http_method(options, env, AXIS2_HTTP_GET); + } + else if (AXIS2_TRUE == method_head) + { + axis2_options_set_http_method(options, env, AXIS2_HTTP_HEAD); + } + else if (AXIS2_TRUE == method_put) + { + axis2_options_set_http_method(options, env, AXIS2_HTTP_PUT); + } + else if (AXIS2_TRUE == method_delete) + { + axis2_options_set_http_method(options, env, AXIS2_HTTP_DELETE); + } + /* Set up deploy folder. It is from the deploy folder, the configuration is picked up + * using the axis2.xml file. + * In this sample client_home points to the Axis2/C default deploy folder. The client_home can + * be different from this folder on your system. For example, you may have a different folder + * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the + * modules that the client uses + */ + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home || !strcmp(client_home, "")) + client_home = "../.."; + + /* Create service client */ + svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + printf + ("Error creating service client, Please check AXIS2C_HOME again\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + return -1; + } + + /* Set service client options */ + axis2_svc_client_set_options(svc_client, env, options); + + /* Build the SOAP request message payload using OM API. */ + payload = build_om_payload_for_echo_svc(env); + + /* Send request */ + ret_node = axis2_svc_client_send_receive(svc_client, env, payload); + + if (ret_node && + axis2_svc_client_get_last_response_has_fault(svc_client, env)) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke FAILED!\n"); + } + else if (ret_node) + { + axis2_char_t *om_str = NULL; + om_str = axiom_node_to_string(ret_node, env); + if (om_str) + { + printf("\nReceived OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + } + printf("\necho client invoke SUCCESSFUL!\n"); + } + else if (method_head && + axis2_svc_client_get_last_response_has_fault(svc_client, env)) + { + /* HEAD request should probably be removed from this file, + * and be relocated to transport unit tests. + */ + printf("\necho client invoke FAILED!\n"); + } + else if (method_head) + { + /* HEAD request should probably be removed from this file, + * and be relocated to transport unit tests. + */ + printf("\necho client invoke SUCCESSFUL!\n"); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Stub invoke FAILED: Error code:" " %d :: %s", + env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("echo client invoke FAILED!\n"); + } + + if (svc_client) + { + axis2_svc_client_free(svc_client, env); + svc_client = NULL; + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + env = NULL; + } + return 0; +} diff --git a/samples/user_guide/clients/echo_rest.mk b/samples/user_guide/clients/echo_rest.mk new file mode 100644 index 0000000..a815594 --- /dev/null +++ b/samples/user_guide/clients/echo_rest.mk @@ -0,0 +1,8 @@ +echo: + @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "AXIS2_DECLARE_EXPORT" /D "_MBCS" echo_rest.C echo_util.c /I.\..\..\..\include /c + @link.exe /nologo echo_rest.obj echo_util.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /OUT:echo_rest.exe + + + + + diff --git a/samples/user_guide/clients/echo_util.c b/samples/user_guide/clients/echo_util.c new file mode 100644 index 0000000..a38158b --- /dev/null +++ b/samples/user_guide/clients/echo_util.c @@ -0,0 +1,48 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "echo_util.h" + +/* build SOAP request message content using OM */ +axiom_node_t * +build_om_payload_for_echo_svc( + const axutil_env_t * env) +{ + axiom_node_t *echo_om_node = NULL; + axiom_element_t *echo_om_ele = NULL; + axiom_node_t *text_om_node = NULL; + axiom_element_t *text_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + axis2_char_t *om_str = NULL; + + ns1 = + axiom_namespace_create(env, "http://ws.apache.org/axis2/services/echo", + "ns1"); + echo_om_ele = + axiom_element_create(env, NULL, "echoString", ns1, &echo_om_node); + text_om_ele = + axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node); + axiom_element_set_text(text_om_ele, env, "Hello World!", text_om_node); + + om_str = axiom_node_to_string(echo_om_node, env); + if (om_str) + printf("\nSending OM : %s\n", om_str); + AXIS2_FREE(env->allocator, om_str); + + return echo_om_node; +} diff --git a/samples/user_guide/clients/echo_util.h b/samples/user_guide/clients/echo_util.h new file mode 100644 index 0000000..19baeb3 --- /dev/null +++ b/samples/user_guide/clients/echo_util.h @@ -0,0 +1,28 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIS2_UG_ECHO_UTIL_H +#define AXIS2_UG_ECHO_UTIL_H + +#include +#include + +axiom_node_t *build_om_payload_for_echo_svc( + const axutil_env_t * env); + +#endif -- cgit v1.1-32-gdbae