Return-Path:
Apache Axis C++ uses WSDL processing tools from Axis Java project and extends those for C/C++ code generation. The following jar files that comes with (or used by) Axis Java are required to run Axis C++ WSDL2Ws tool: The following jar files that come with (or used by) Axis Java are required to run Axis C++ WSDL2Ws tool: "SchemaUtils" (SchemaUtils.java) and "ElementDecl" (ElementDecl.java) classes of Axis Java tools have been overridden by Axis C++ WSDL2Ws implementation. "SchemaUtils" and "ElementDecl" classes of Axis Java tools have been extended by Axis C++ WSDL2Ws implementation. Other than the two classes mentioned above, no other class from Axis Java WSDL tool implementation has been overridden or extended at present by Axis C++ WSDL2Ws tool; hence all other classes in Axis Java tool are used as they are. Except for "SchemaUtils" and "ElementDecl" classes, the rest of the classes of Axis C++ WSDL2Ws are unique to Axis C++ and they use functionality form Axis Java jars. If you want to build the WSDL2Ws tool form source, there is an Apache Ant build script to help you.
+ If you want to build the WSDL2Ws tool from source, there is an Apache Ant build script to help you.
Assuming that you have installed Ant properly, what you have to do is to set the CLASSPATH to include Axis Java jar files mentioned in the previous section and run ant command in $AXISCPP_HOME/src/wsdl folder. Once you build the tool the generated wsdl2ws.jar file would be placed in $AXISCPP_HOME/lib/axis/ folder.
Alternatively, you can use the -classpath option of java command to specify the CLASSPATH. NOTE: It is a MUST that that you have wsdl2ws.jar from Axis C++ appearing before all the jar files form Axis Java on the CLASSPATH. If not you will run into trouble when generating code. This is a known problem and happens because the two classes, "SchemaUtils" and "ElementDecl", of Axis C++ that overides Axis Java classes with the same name have identical package names to that of Axis Java classes.
-
- The build files are available at: Change your current directory to this directory and then execute the following... The handler libeshhandler.so file will be created at The VC dsw file (ServerHandlers.dsw) is available at Open this file and build the project echoStringHeaderHandler. Once the build is successful you will find the DLL (
+echoStringHeaderHandler.dll) at: Edit the server.wsdd file
-(as
+(as
created when you configured your server
)
to include the handler for a
particular service. <service name="Calculator" provider="CPP:RPC" description="Simple Calculator Axis C++ Service ">
-
-<requestFlow name="CalculatorHandlers">
-<handler name="ESHHandler" type="<Axis installation
-directory>/handlers/custom/echoStringHeaderHandler/libeshhandler.so">
-
-</handler>
-</requestFlow>
-<responseFlow name="CalculatorHandlers">
-<handler name="ESHHandler" type="<Axis installation
-directory>AXISCPP_DEPLOY/lib/libeshhandler.so">
-</handler>
-</responseFlow>
-
-<parameter name="allowedMethods" value="add sub mul div "/>
-<parameter name="className" value="<Axis installation
-directory>/webservices/libcalculator.so" />
-</service>
-
+
Since this Handler is configured to the Calculator web service in the above step, this Handler will be executed when a client sends a SOAP
-request to the Calculator web service. Use the calculator
+request to the Calculator web service. Use the calculator
client you created earlier.
@@ -90,7 +90,7 @@
2.1 Dependencies on Axis Java tool
-2.2 Building the Tool
-
-o(folder) target output folder - default is current folder
-l(c++|c) target language (c++|c) - default is c++
--s(server|client) generate server skeletons or client stubs? (serve|client) - default is server
+-s(server|client) generate server skeletons or client stubs? (server|client) - default is server
-w(wrapped|nonwrapped) wrapping style of the WSDL (wrapped|nonwrapped) - default is wrapped
-verbose, -v be verbose
--m(none|gnu) generate make files (none|gnu) - default is none
@@ -147,9 +144,6 @@
set CLASSPATH=%AXISCPP_HOME%\lib\axis\wsdl2ws.jar;%CLASSPATH%
2.5 Running the Tool
Modified: webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/handler.ihtml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/handler.ihtml?rev=382070&r1=382069&r2=382070&view=diff
==============================================================================
--- webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/handler.ihtml (original)
+++ webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/handler.ihtml Wed Mar 1 08:15:23 2006
@@ -42,57 +42,45 @@
Building the echoStringHeaderHandler
Linux
-The build files are available at
-
-<Axis install directory>/samples/server/echoStringHeaderHandler
-Change your current directory to this directory and then execute the
-following...
-
+
-<Axis install directory>/samples/server/echoStringHeaderHandler
+
-The handler libeshhandler.so file will be created at <Axis
-install directory>/lib directory
Windows
-The VC dsw file (ServerHandlers.dsw) is available at
-<Axis Install directory>/vc/samples/server/
-ServerHandlers.dsw.
-Open this file and build the project echoStringHeaderHandler. Once the build is successful you will find the DLL (
-echoStringHeaderHandler.dll) at<Axis install
-directory>/bin
+<Axis install directory>/lib directory
+Windows
+<Axis Install directory>/vc/samples/server/ServerHandlers.dsw.
+<Axis install directory>/bin
Configuring the echoStringHeader Handler
-In this instance we are using the Calculator server example that we have used in both the client and server setup examples. The example below shows how a linux file would look e.g. libeshhandler.so is used please vary the file according to the libraries you have created. This example shows the handler being deployed on both the incoming and outgoing message.
+In this instance we are using the Calculator server example that we have used in both the client and server setup examples. The example below shows how a linux file would look e.g. libeshhandler.so is used please vary the file according to the libraries you have created. This example shows the same handler being deployed on both the incoming and outgoing message.
-<service name="Calculator" provider="CPP:RPC" description="Simple Calculator Axis C++ Service">
+ <requestFlow name="CalculatorHandlers">
+ <handler name="ESHHandler" type="<Axis installation directory>/handlers/custom/echoStringHeaderHandler/libeshhandler.so">
+ </handler>
+ </requestFlow>
+ <responseFlow name="CalculatorHandlers">
+ <handler name="ESHHandler" type="<Axis installation directory>/handlers/custom/echoStringHeaderHandler/libeshhandler.so">
+ </handler>
+ </responseFlow>
+ <parameter name="allowedMethods" value="add sub mul div"/>
+ <parameter name="className" value="<Axis installation directory>/webservices/libcalculator.so" />
+</service>
@@ -105,7 +93,7 @@
Running the echoStringHeader Handler
The build files are available at -<Axis installation directory>/samples/client/testHandler. Change your current directory to this direcotory and then you could execute the following. +<Axis installation directory>/samples/client/testHandler. Change your current directory to this directory and then you can execute the following.
--
+-Linux
-
- make
- make install
The handler so file will be created at <Axis -installation directory>/lib/ -
The VC dsw file (ClientHandlers.dsw) is available at <Axis -Installation directory>/vc/samples/client/ClientHandlers.dsw.Open this file and -build the project TestHandler.-
Once the build is successful you will find the DLL -testHandler.dll) at <Axis Installation directory>/bin. If you see this DLL at the above -location you are done with the first step.- +
The handler so file will be created at
+<Axis installation directory>/lib/+
The VC dsw file (ClientHandlers.dsw) is available at:
+<Axis Installation directory>/vc/samples/client/ClientHandlers.dsw+
Open this file and build the project TestHandler.
+Once the build is successful you will find the DLL (testHandler.dll) at: +
<Axis Installation directory>/bin+
If you see this DLL at the above location you are done with the first step.
@@ -148,14 +132,12 @@ Up until this point you did not need a client wsdd file the client only requires a wsdd file when it has handlers.
-<service name="Calculator" provider="CPP:RPC" -description="Calculator web service"> -<requestFlow name="CalculatorHandlers"> -<handler name="TestHandler" -type="<Axis Installation directory>/lib/libtest_client_handler.so"> -</handler> -</requestFlow> -</service>
+<service name="Calculator" provider="CPP:RPC" description="Calculator web service"> + <requestFlow name="CalculatorHandlers"> + <handler name="TestHandler" type="<Axis Installation directory>/lib/libtest_client_handler.so"> + </handler> + </requestFlow> +</service>@@ -164,14 +146,14 @@ Note: If you are using Client side Handlers you need to enter the ClientWSDDFilePath entry in your axiscpp.conf configuration file. + href="../install-guide.html#Installing_Client">axiscpp.conf configuration file.
Since this Handler is configured to the Calculator web service in the above step, this Handler will be executed when you run the calculator + href="../clientuser-guide.html#Generating_and_using_client_stubs">calculator web service client..
Modified: webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/mem-management.ihtml URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/mem-management.ihtml?rev=382070&r1=382069&r2=382070&view=diff ============================================================================== --- webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/mem-management.ihtml (original) +++ webservices/axis/trunk/site/src/cpp/src/documentation/content/xdocs/cpp/arch/mem-management.ihtml Wed Mar 1 08:15:23 2006 @@ -1,111 +1,194 @@ - +1.0 Version
+Feedback: axis-c-dev@ws.apache.org
+ +Introduction
+Allocation/De-allocation Semantics
+Dealing with SOAP Headers
+Windows Issues
This guide records the memory management semantics and some of the rationales of the design decisions on which memory management semantics are based on. Being a C/C++ application, it is a must that all users as well as developers have a clear understanding on how to deal with memory allocation and deallocation. -
The allocation and deallocation mechanisms are centered around the serializer and deserializer operations in Axis C++. At the moment, because Axis C++ support both C and C++ clients and services, the deserializer uses malloc() for memory allocation. Hence C++ users may have to live with free() (instead of delete) for deallocation. Of course one could still use delete from C++ programs, however this may not guarantee the cleanest memory deallocation. - -
The values returned by the Axis C++ engine must be memory cleaned by the user written code. -The C++ code generated by the WSDL2Ws tool does contain destructors. However, at the moment, it is not gauranteed that the destructor of a generated class would clean all the pointer members (Some members are cleaned while others are not). Hence the users must have a look at the generated code to understand the semantics of memory cleaning. In case of C code, of course the user must take care of memory cleaning. -
Please note that in case of arrays, both for C and C++, the Axis C++ engine returns a struct. Hence it is a must that the memory is cleaned properly.
-
C++ Example:
-
- // testing echoIntegerArray - xsd__int_Array arrint; // Parameter for method call - arrint.m_Array = new int[ARRAYSIZE]; - arrint.m_Size = ARRAYSIZE; - - for (x = 0; x < ARRAYSIZE; x++) - { - arrint.m_Array[x] = x; - } - - printf ("invoking echoIntegerArray...\n"); - - xsd__int_Array arrintResult = ws.echoIntegerArray (arrint); - - // Deal with the return value - if (arrintResult.m_Array != NULL) - { - printf ("successful\n"); - // Clean memory of the returned array - free(arrintResult.m_Array); - } - else - printf ("failed\n"); - - // Clean memory allocated for parameter - delete [] arrint.m_Array; --
Memory management is very important and if not handled correctly, +will quickly consume resources and slow down your application. The basic rules are;-
+For client applications,
+For server applications,
+Within the client or service applications, all memory object must be +created using 'new' and deleted using 'delete' (The C style memory functions +'malloc' and 'free', or any of their variants must not be used).
+ +If you are using the wrappers produced by WSDL2Ws then a lot of the +memory management is handled for you within the generated code. You +still have to follow the rules for client or service, but there may be some +additional steps that you will have to follow.
+ +The following examples rely on the application is using the stubs generated +by the WSDL2Ws tool. If the user needs to use the Axis API directly, it is +assumed that they know what methods to call and how these methods have been +bundled by the generated code.
+ +If the object is not nillable, then use the basic type. For example, if
+the web service requires an xsd__byte
value, then the client/service code would
+be as follows;-
webService->asNonNillableElement( (xsd__byte) 127)+
If the object is nillable, then use a pointer to the basic type. For
+example, if the web service requires a pointer to a xsd__byte
value, then the
+client/service code would be as follows;-
xsd__byte * pNillableInput = new xsd__byte();+
+*(pNillableInput) = (xsd__byte) 123;
+webService->asNillableElement( pNillableInput);
+delete pNillableInput;
Notice that once the client/service code no longer requires the +pNillableObject object, it is deleted (and must be deleted by the +client/service code).
+ +Arrays and Complex Types are treated as nillable, even if they are not.
+For example, if the web service requires an array of xsd__byte
values,
+then the client/service code would be as follows;-
// Need an xsd__byte array of 2 elements,+
+// each element is assigned the value 123.
+int arraySize = 2;
+xsd__byte ** array = new xsd__byte*[arraySize];
+for ( int inputIndex = 0 ; inputIndex < arraySize ; inputIndex++ )
+array[inputIndex] = new xsd__byte( 123);
+// Now copy this array into the xsd__byte_Array
+// that will be used to pass to the web service.
+xsd__byte_Array arrayInput;
+arrayInput.set( array, arraySize);
+// Call the web service.
+webService->asArray( &arrayInput);
+// Clear up input array
+for ( int deleteIndex = 0 ; deleteIndex < arraySize ; deleteIndex++ )
+{
+ delete
+ array[deleteIndex];
+}
+delete [] array;
Which is exactly the same code as would be used if the array was not nillable.
+The following examples rely on the application is using the stubs generated +by the WSDL2Ws tool. If the user needs to use the Axis API directly, it is +assumed that they know what methods to call and how these methods have been +bundled by the generated code.
+ +If the returned object is not nillable, then use the basic type. For
+example, if the web service returns a xsd__byte
value, then the client/service
+code would be as follows;-
xsd__byte result = webService->asNonNillableElement( (xsd__byte) 127);+
If the object is nillable, then use a pointer to the basic type. For
+example, if the web service returns a pointer to a xsd__byte
value, then the
+client/service code would be as follows;-
xsd__byte * pNillableOutput = webService->asNonNillableElement( (xsd__byte) 127);+
+delete pNillableOutput;
Notice that once the client/service code no longer requires the
+pNillableOutput
object, it is deleted (and must be deleted by the client/service code).
Arrays and Complex Types are treated as nillable, even if they are not.
+For example, if the web service returns an array of xsd__byte
values, then
+the client/service code would be as follows;-
// Call the web service.+
+xsd__byte_Array * arrayOutput = webService->getArray();
+// Retrieve the information within the array.
+int byteArraySize = 0;
+const xsd__byte ** byteArray = arrayOutput->get( byteArraySize);
+// Clear up output array +delete arrayOutput;
Which is exactly the same code as would be used if the array was not
+nillable. Notice that only the arrayOutput
object (that is returned
+ by the web service) needs to be deleted. The byteArray
object is a
+ pointer to the contents of the arrayOutput
object so must not be
+ deleted.
IHeaderBlock is a virtual class that defines the interface to deal with SOAP headers. You can create an IHeaderBlock at the client side using the API provided with Stub classes.
-
-IHeaderBlock* Stub::createSOAPHeaderBlock(AxisChar * pachLocalName, AxisChar * pachUri); --Here the Stub class will maintain a list of all the created Header Blocks, and in the destructor of the Stub class, it will clean up memory by deleting all those Header Blocks that were created by the user. - -
Note 1: It is advisable that if a user wants to delete a Hheader Block, (s)he uses the API provided by the Stub class to do so.
-
-void deleteCurrentSOAPHeaderBlock(); --Stub class is also equipped with iterator methods to traverse through the current list of Header Blocks created. -
Note 2: IHeaderBlock destructor will take care of the Header Block member variables and cleans them; BasicNodes (i.e its children) and the Attributes.
+
IHeaderBlock is a virtual class that defines the interface to deal with SOAP headers. +To create an IHeaderBlock in the client application, use the API provided with Stub classes, +i.e. ;-
> +IHeaderBlock * Stub::createSOAPHeaderBlock( AxisChar * pachLocalName, AxisChar * pachUri);+
The Stub class methods that handle header blocks keeps a list of all the created + header blocks. When the destructor is called, it will clean up memory + by deleting the header blocks that were created using the + cerateSOAPHeaderBlock method.
+Note 1: The client/service + application must use the appropriate Stub method to delete a header block, + i.e. ;-
+void deleteCurrentSOAPHeaderBlock();+ +
Note 2: The IHeaderBlock destructor will take care of the header block member variables
+(for example, BasicNodes may have children and attributes. These will be
+deleted when the parent is deleted.).
If the Header Blocks are created within a Handler then it is the responsibility of the Handler writer to clean those. For that the user can write the cleanup code either in the fini() method or in the destructor of the Handler, depending on the following situations +
If header blocks are created within a 'Handler' then it is the responsibility of the +'Handler' writer to delete them. The deletion would occur in the 'clean-up' code either in the fini() +method or in the destructor of the Handler, depending on the following rules;-
If a target handler access a header block created by the de-serializer then it is the responsibility of the Handler to delete it.
-If a target handler access a Header Block created by the deserializer then it is the responsibility of the Handler to delete it. - -
When an array is de-serialized it uses C style memory re-allocation mechanism in the present code. C++ does not support realloc() and if we use new instead we have to allocate fresh memory blocks each time we need to increase the array size. This can be more expensive than using realloc(). Again the price paid for efficiency is that one has to use free() and not delete [] from C++ code. - +
For Windows platforms, everything must built with the compiler flag '/MD' +regardless whether it is a DLL or an EXE. There are still problems however +when passing objects over process boundaries. If an object is created in +one process (say the Axis engine DLL) and then passed to another (say the client +application) then when the client tries to delete that object, it cannot find it +on its own process heap and throws an exception. This is because the +client process does not own the memory object. To overcome this problem, +on the process boundary, the original object is cloned (the clone uses the +client heap) and then the original object is freed from the engine heap. +Here is an example taken from the wrapper code created by WSDL2Ws from the +Arrays unit test (Arrays.cpp);-
+xsd__int_Array * Arrays::simpleArray( xsd__int_Array* Value0)+
+{
+ xsd__int_Array * RetArray = new xsd__int_Array();
+ :
+ :
+ if ( AXIS_SUCCESS == m_pCall->invoke())
+ {
+ if ( AXIS_SUCCESS == m_pCall->checkMessage( "simpleArrayResponse", "http://org.apache.axis/Arrays/"))
+ {
+ Axis_Array * RetAxisArray = m_pCall->getBasicArray( XSD_INT, "simpleType", 0);
+ RetArray->clone( *RetAxisArray);
+ Axis::AxisDelete( (void*) RetAxisArray, XSD_ARRAY);
+ +}
}
+ m_pCall->unInitialize(); +
return +RetArray;
+}
The two lines of interest are the cloning of the memory object (RetAxisArray +exists within the engine heap) into the RetArray memory object (that exists +within the client heap) and then the deletion of the RetAxisArray by calling the +AxisDelete method (which exists within the engine process and hence will be able +to delete the object from that heap).
- - +