Return-Path:
This document will guide you on how to install Axis2/C and run the server
-and client samples on Linux and Microsoft Windows operating systems. This document guides you on how to install Axis2/C, and run the server and
+client samples on Linux and Microsoft Windows operating systems. This release comes in two forms, source and binary. This document covers both those forms. This release comes in two forms, source and binary. This document covers
+both forms. Please send your feedback to the developer mailing list: axis-c-dev@ws.apache.org (please
-remember to prefix the subject with [Axis2]). To subscribe to developer
-mailing list see here.Apache Axis2/C Installation Guide
-
This can be done using binary or source distributions.(You can download the two distributions here)
+This can be done using binary or source distributions. (Download the two +distributions)
-To get both the binary and source distributions working, you need -Libxml2.
- -Note : Most Linux systems have Libxml2 installed by default. On MS -Windows you need to download and install Libxml2.
+To get both the binary and source distributions working, you need Libxml2.
+Note: Most Linux systems have Libxml2 installed by default. On MS +Windows, you need to download and install Libxml2.
-The following steps need to be followed to install and run -Axis2/C binary distribution on Linux : -
+The following steps have to be followed to install and run the Axis2/C +binary distribution on Linux :
Note : You will need to set AXIS2C_HOME only if you - need to run Axis2/C samples. The reason is that the samples - use AXIS2C_HOME to get the path to Axis2/C repository. To write your own - services or clients this is not a requirement.
+Note: You will need to set the AXIS2C_HOME only if + you need to run the Axis2/C samples. The reason is that the samples use + AXIS2C_HOME to get the path to the Axis2/C repository. This is not + required to write your own services or clients.
Note : If you run into shared library problems, try - setting the LD_LIBRARY_PATH to include the lib folder containing the Axis2/C libs.
+Note: If you run into shared library problems, + try setting the LD_LIBRARY_PATH to include the lib folder containing + the Axis2/C libs.
Note : If you run into shared library problems, try +
Note: If you run into shared library problems, try setting the LD_LIBRARY_PATH
The following steps need to be followed to install and run Axis2/C using -source distribution on Linux : -
+The following steps have to be followed to install and run Axis2/C using +the source distribution on Linux :
Note : You will need to set AXIS2C_HOME only if you - need to run Axis2/C samples. The reason is that the samples - use AXIS2C_HOME to get the path to Axis2/C repository. To write your own - services or clients this is not a requirement.
+Note: You will have to set AXIS2C_HOME only if you + want to run the Axis2/C samples. The reason is that the samples use + AXIS2C_HOME to get the path to the Axis2/C repository. This is not + required to write your own services or clients.
This too can be done using either binary or source distributions. -(You can download the two distributions here)
- -For both the binary and source distributions, you need to -download Libxml2.
+This too can be done using binary or source distributions. (Download the two +distributions.)
+For both binary and source distributions, you have to download Libxml2.
-(Note: you can download Microsoft VSExpress2005 edition - from the Microsoft Web site and install it to run these binaries)
+(Note: you can download the + Microsoft VSExpress2005 edition from the Microsoft Web site and install + it to run these binaries.)
The above folders contain the following files:
- C:\axis2c\bin\>axis2_http_server.exe
C:\axis2c\bin\>axis2_http_server.exe
+(Note: You can download Microsoft VSExpress2005 edition and Platform SDK - from Microsoft Web site. You will need to add the path to Platform SDK - Include and Lib folders to makefile)
+(Note: You can download the + Microsoft VSExpress2005 edition and Platform SDK from the Microsoft Web + site. You will need to add the path to the Platform SDK Include and Lib + folders to the makefile)
Please edit <source_distribution>\build\win32\configure.in file to include following information.
+Please edit the <source_distribution>\build\win32\configure.in file +to include the following information.
Or extract to a location of your choice and edit the configure.in - accordingly.
+Else, extract it to a location of your choice and edit the configure.in + file accordingly.
The following steps will take you through the source compilation
+The following steps will take you through the source compilation.
(Note: You may need to set the PATH environment variable to - vcvars32.bat if Windows complaints that it cannot find this batch file. This file is located in - <your MS Visual Studio install Directory>\VC\bin directory.)
+(Note: You may have to set the PATH environment + variable to vcvars32.bat if MS Windows gives an error indicating that it + cannot find this batch file. This file is located in <your MS Visual + Studio install Directory>\VC\bin directory.)
AXIOM stands for AXis Object Model and refers to -the XML infoset model that is developed for Axis2. XML infoset refers to the -information included inside the XML. For programmatical manipulation it is -convenient to have a representation of this XML infoset in a language -specific manner. DOM and JDOM are two such XML models. AXIOM is conceptually -similar to such an XML model by its external behavior but deep down it is -very much different.
+AXIOM stands for AXis Object Model and refers to the XML infoset model +that is developed for Apache Axis2. XML infoset refers to the information +included inside the XML. For programmatical manipulation, it is convenient to +have a representation of this XML infoset in a language specific manner. DOM +and JDOM are two such XML models. AXIOM is conceptually similar to such an +XML model in its external behavior but deep down it is very different.
The objective of this tutorial is to introduce the basics of AXIOM/C and -explain best practices while using AXIOM.
+explain the best practices while using AXIOM. -AXIOM/C is a C equivalant of AXIOM/Java. We have done our best to get almost -the same kind of API in C.
+AXIOM/C is a C equivalant of AXIOM/Java. We have done our best to get +almost the same kind of API in C.
-This tutorial can be used by anybody who is interested and wants to go deeper in to AXIOM/C. Knowledge in similar object models such as DOM will be -quite helpful in understanding AXIOM but such knowledge is not assumed. Several -links are listed in the links section that will help understand the -basics of XML.
+helpful in understanding AXIOM, but such knowledge has not been assumed. +Several links are listed in the links section that will help you understand +the basics of XML.AXIOM is a lightweight, differed built XML infoset representation based on -StAX API derived form (JSR -173), which is the standard streaming pull parser API. AXIOM can be -manipulated as flexibly as any other object model (such as JDOM), but underneath the objects will be +173, which is the standard streaming pull parser API. AXIOM can be +manipulated as flexibly as any other object model such as JDOM, but underneath, the objects will be created only when they are absolutely required. This leads to much less -memory intensive programming.
+memory-intensive programming. -Following is a short feature overview of AXIOM.
+The following is a short feature overview of AXIOM.
Since different XML parsers offer different kinds of pull parser APIs,
we define an API derived from StAX. That API is defined in
- axiom_xml_reader.h
. Similarly we define an XML writer API in
- axiom_xml_writer.h
. These two APIs work as an abstarction
+ axiom_xml_reader.h
. Similarly, we define an XML writer API
+ in axiom_xml_writer.h
. These two APIs work as an abstarction
layer between any XML parser and AXIOM. So any parser that is going to be
used for AXIOM should implement the axiom_xml_reader
API and
- axiom_xml_writer
API using a wrapper layer.
axiom_xml_writer
API using a wrapper layer.
- Currenly we use Libxml2 as our default XML parser.
+Currenly we use Libxml2 as our default XML + parser.
AXIOM Builder wraps the raw XML character stream through the +
The AXIOM Builder wraps the raw XML character stream through the
axiom_xml_reader
API. Hence the complexities of the pull event
-stream are hidden form the user.
In a nutshell SOAP is an information exchange protocol based on XML. SOAP -has a defined set of XML elements that should be used in messages. Since Axis2 -is a "SOAP Engine" and AXIOM is designed for Axis2, a SOAP specific API was -implemented on top of AXIOM. We have defined a number of structs to represent -SOAP constructs, which wraps general AXIOM structures. See here to learn more -about SOAP.
+In a nutshell, SOAP is an information exchange protocol based on XML. SOAP +has a defined set of XML elements that should be used in messages. Since +Axis2 is a "SOAP Engine" and AXIOM is designed for Axis2, a SOAP specific API +was implemented on top of AXIOM. We have defined a number of structs to +represent SOAP constructs, which wrap general AXIOM structures. Learn more +about SOAP.
- +AXIOM can be serialized using axiom_node_serialize
function.The
-serialization uses axiom_xml_writer.h
and
+
AXIOM can be serialized using the axiom_node_serialize
+function. The serialization uses axiom_xml_writer.h
and
axiom_output.h
APIs.
Here is an example that shows how to write the output to the console (we have -serialized the SOAP envelope created in code listing 1).
+Here is an example that shows how to write the output to the console (we +have serialized the SOAP envelope created in code listing 1).
Code Listing 8
axiom_xml_writer_t *xml_writer = NULL; @@ -567,20 +559,20 @@ printf("%s", xml_output); AXIS2_FREE(env->allocator, xml_output);-
Note that freeing the returned buffer is user's responsibility.
- +Note that freeing the returned buffer is the user's responsibility.
+axiom_xml_reader
provides three create functions that can
-be used for different xml input sources.
axiom_xml_reader
provides three create functions that can be
+used for different XML input sources.
axiom_xml_reader_create_for_file
function can be used to
- read from a fileaxiom_xml_reader_create_for_file
can be used to read from
+ a fileaxiom_xml_reader_create_for_io
uses a user defined
- callback function to pull xmlaxiom_xml_reader_create_for_memory
can be used to read
- from an xml string that is in a character bufferSimilarly axiom_xml_writer
provides two create functions.
axiom_xml_writer_create_for_file
can be used to write to a
fileaxiom_xml_writer_create_for_memory
can be used to write to
- an internal memory buffer and obtain the XML string as a character buffer
- axiom_xml_writer.h
for more information.
-
-You have to be extremely careful when using AXIOM, in order to avoid memory -leaks and double free errors. The following guidelines will be extremely useful:
-1. axiom_element
struct keeps a list of attributes and a list
-of namespaces, when an axiom_namespace
pointer or an axiom_attribute
pointer
-is added to these lists, that will be
-freed when the axiom_element
is freed. Therefore a pointer to a namespace or
-an attribute should not be freed, once that is used with an axiom_element
.
To avoid the inconvenience, clone functions have been implemented for both
-axiom_namespace
and axiom_attribute
structures.
You have to be extremely careful when using AXIOM, in order to avoid +memory leaks and double free errors. The following guidelines will be +extremely useful:
+ +1. The axiom_element
struct keeps a list of attributes and a
+list of namespaces, when an axiom_namespace
pointer or an
+axiom_attribute
pointer is added to these lists, which will be
+freed when the axiom_element
is freed. Therefore a pointer to a
+namespace or an attribute should not be freed, once it is used with an
+axiom_element
.
To avoid any inconvenience, clone functions have been implemented for both
+the axiom_namespace
and axiom_attribute
+structures.
2. AXIOM returns shallow references to its string values. Therefore, when
-you want deep copies of returned values, axutil_strdup()
function should be used to avoid
-double free errors.
axutil_strdup()
+function should be used to avoid double free errors.
Example
@@ -629,151 +624,158 @@uri = axiom_namespace_get_uri(ns, env);
/* now uri points to the same place where namespace struct's uri
-pointer is pointing. Therefore following will cause a double free */
/* now uri points to the same place where namespace struct's uri
+pointer is pointing. Therefore following will cause a double free
+*/
AXIS2_FREE(env->allocator, uri);
axiom_namespace_free(ns, env);
3. When creating AXIOM programatically , if you are declaring a namespace with
-an axiom_element
, it is advisable to find whether the namespace is already
-available in the elements scope using axiom_element_find_namespace
function. If available,
-that pointer can be used instead of creating another namespace struct
-instance to minimize memory usage.
3. When creating AXIOM programatically, if you are declaring a namespace
+with an axiom_element
, it is advisable to find whether the
+namespace is already available in the elements scope using the
+axiom_element_find_namespace
function. If available, that
+pointer can be used instead of creating another namespace struct instance to
+minimize memory usage.
The following code segment shows how to use the AXIOM for completely building -a document and then serializing it into text pushing the output to the + +
The following code segment shows how to use AXIOM for building a document +completely and then serializing it into text, pushing the output to the console.
+ -Code Listing 10
-#include <axiom.h> -#include <axis2_util.h> -#include <axutil_env.h> -#include <axuitl_log_default.h> -#include <axutil_error_default.h> -#include <stdio.h> +Code Listing 10
+#include <axiom.h> +#include <axis2_util.h> +#include <axutil_env.h> +#include <axuitl_log_default.h> +#include <axutil_error_default.h> +#include <stdio.h> -FILE *f = NULL; -int read_input_callback(char *buffer, int size, void* ctx) +FILE *f = NULL; +int read_input_callback(char *buffer, int size, void* ctx) { - return fread(buffer, sizeof(char), size, f); + return fread(buffer, sizeof(char), size, f); } -int close_input_callback(void *ctx) +int close_input_callback(void *ctx) { - return fclose(f); + return fclose(f); } -axutil_env_t * create_environment() +axutil_env_t * create_environment() { - axutil_allocator_t *allocator = NULL; - axutil_env_t *env = NULL; - axuitl_log_t *log = NULL; - - axutil_error_t *error = NULL; - allocator = axutil_allocator_init(NULL); - log = axuitl_log_create(allocator, NULL, NULL); - - error = axutil_error_create(allocator); - env = axutil_env_create_with_error_log(allocator, error, log); - return env; + axutil_allocator_t *allocator = NULL; + axutil_env_t *env = NULL; + axuitl_log_t *log = NULL; + + axutil_error_t *error = NULL; + allocator = axutil_allocator_init(NULL); + log = axuitl_log_create(allocator, NULL, NULL); + + error = axutil_error_create(allocator); + env = axutil_env_create_with_error_log(allocator, error, log); + return env; } -build_and_serialize_om(axutil_env_t *env) +build_and_serialize_om(axutil_env_t *env) { - axiom_node_t *root_node = NULL; + axiom_node_t *root_node = NULL; - axiom_element_t *root_ele = NULL; - axiom_document_t *document = NULL; - axiom_stax_builder_t *om_builder = NULL; - - axiom_xml_reader_t *xml_reader = NULL; - axiom_xml_writer_t *xml_writer = NULL; - axiom_output_t *om_output = NULL; - - axis2_char_t *buffer = NULL; - - f = fopen("test.xml","r"); - xml_reader = axiom_xml_reader_create_for_io(env, read_input_callback, - close_input_callback, NULL, NULL); - if(!xml_reader) - return -1; - - om_builder = axiom_stax_builder_create(env, xml_reader); - if(!om_builder) - { - AXIOM_XML_READER_FREE(xml_reader, env); - return AXIS2_FAILURE; - } - document = AXIOM_STAX_BUILDER_GET_DOCUMENT(om_builder, env); - if(!document) - { - AXIOM_STAX_BUILDER_FREE(om_builder, env); - return AXIS2_FAILURE; - } - - root_node = AXIOM_DOCUMENT_GET_ROOT_ELEMENT(document, env); - if(!root_node) - { - AXIOM_STAX_BUILDER_FREE(om_builder, env); - return AXIS2_FAILURE; - } - if(root_node) - { - if(AXIOM_NODE_GET_NODE_TYPE(root_node, env) == AXIOM_ELEMENT) - { - root_ele = (axiom_element_t*)AXIOM_NODE_GET_DATA_ELEMENT (root_node, env); - if(root_ele) - { - printf(" %s" , AXIOM_ELEMENT_GET_LOCALNAME(root_ele, env)); - } - } - } - AXIOM_DOCUMENT_BUILD_ALL(document, env); - - xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, AXIS2_XML_PARSER_TYPE_BUFFER); - - om_output = axiom_output_create(env, xml_writer); - - AXIOM_NODE_SERIALIZE(root_node, env, om_output); - buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env); - - printf("The output XML is ->>>>\n %s ", buffer); - - - /** when om_output is freed xml_writer is also freed */ - - AXIOM_OUTPUT_FREE(om_output, env); - - /** when om_builder is freed , the builder, om_document and the entire AXIOM structure is freed */ - AXIOM_STAX_BUILDER_FREE(om_builder, env); - - AXIS2_FREE(env->allocator, buffer); - - return AXIS2_SUCCESS; - + axiom_element_t *root_ele = NULL; + axiom_document_t *document = NULL; + axiom_stax_builder_t *om_builder = NULL; + + axiom_xml_reader_t *xml_reader = NULL; + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + + axis2_char_t *buffer = NULL; + + f = fopen("test.xml","r"); + xml_reader = axiom_xml_reader_create_for_io(env, read_input_callback, + close_input_callback, NULL, NULL); + if(!xml_reader) + return -1; + + om_builder = axiom_stax_builder_create(env, xml_reader); + if(!om_builder) + { + AXIOM_XML_READER_FREE(xml_reader, env); + return AXIS2_FAILURE; + } + document = AXIOM_STAX_BUILDER_GET_DOCUMENT(om_builder, env); + if(!document) + { + AXIOM_STAX_BUILDER_FREE(om_builder, env); + return AXIS2_FAILURE; + } + + root_node = AXIOM_DOCUMENT_GET_ROOT_ELEMENT(document, env); + if(!root_node) + { + AXIOM_STAX_BUILDER_FREE(om_builder, env); + return AXIS2_FAILURE; + } + if(root_node) + { + if(AXIOM_NODE_GET_NODE_TYPE(root_node, env) == AXIOM_ELEMENT) + { + root_ele = (axiom_element_t*)AXIOM_NODE_GET_DATA_ELEMENT (root_node, env); + if(root_ele) + { + printf(" %s" , AXIOM_ELEMENT_GET_LOCALNAME(root_ele, env)); + } + } + } + AXIOM_DOCUMENT_BUILD_ALL(document, env); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, AXIS2_XML_PARSER_TYPE_BUFFER); + + om_output = axiom_output_create(env, xml_writer); + + AXIOM_NODE_SERIALIZE(root_node, env, om_output); + buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env); + + printf("The output XML is ->>>>\n %s ", buffer); + + + /** when om_output is freed xml_writer is also freed */ + + AXIOM_OUTPUT_FREE(om_output, env); + + /** when om_builder is freed , the builder, om_document and the entire AXIOM structure is freed */ + AXIOM_STAX_BUILDER_FREE(om_builder, env); + + AXIS2_FREE(env->allocator, buffer); + + return AXIS2_SUCCESS; + } -int main() +int main() { - int status = AXIS2_SUCCESS; - - axutil_env_t *env = NULL; - axutil_allocator_t *allocator = NULL; - env = create_environment(); -Modified: webservices/axis2/scratch/c/neethi/axis2c/xdocs/navigation.xml URL: http://svn.apache.org/viewvc/webservices/axis2/scratch/c/neethi/axis2c/xdocs/navigation.xml?view=diff&rev=532305&r1=532304&r2=532305 ============================================================================== --- webservices/axis2/scratch/c/neethi/axis2c/xdocs/navigation.xml (original) +++ webservices/axis2/scratch/c/neethi/axis2c/xdocs/navigation.xml Wed Apr 25 03:39:55 2007 @@ -6,20 +6,23 @@
- status = build_and_serialize_om(env); -
- if(status == AXIS2_FAILURE) - { - printf(" build AXIOM failed"); - } - - axutil_env_free(env); - - return 0; + int status = AXIS2_SUCCESS; + + axutil_env_t *env = NULL; + axutil_allocator_t *allocator = NULL; + env = create_environment(); +
+ status = build_and_serialize_om(env); +
+ if(status == AXIS2_FAILURE) + { + printf(" build AXIOM failed"); + } + + axutil_env_free(env); + + return 0; }- -
- -
- -
- -
- +
- +
+- +
- +
- +
- +
- --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org
- -
- +