You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/03/20 07:27:22 UTC

svn commit: r387150 [2/3] - in /webservices/axis2/site/c: ./ M0_5/

Modified: webservices/axis2/site/c/M0_5/userguide2.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/site/c/M0_5/userguide2.html?rev=387150&r1=387149&r2=387150&view=diff
==============================================================================
--- webservices/axis2/site/c/M0_5/userguide2.html (original)
+++ webservices/axis2/site/c/M0_5/userguide2.html Sun Mar 19 22:27:20 2006
@@ -2,286 +2,304 @@
           @import url("../style/maven-base.css");
           
 			    @import url("../style/maven-classic.css");</style><link rel="stylesheet" href="../style/print.css" type="text/css" media="print"></link><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta></head><body class="composite"><div id="banner"><a href="http://www.apache.org/" id="organizationLogo"><img alt="Apache Software Foundation" src="http://www.apache.org/images/asf-logo.gif"></img></a><a href="http://ws.apache.org/axis2/c" id="projectLogo"><img alt="Apache Axis2 C" src="http://ws.apache.org/axis2/images/axis.jpg"></img></a><div class="clear"><hr></hr></div></div><div id="breadcrumbs"><div class="xleft">
-                	Last published: 10 March 2006
-                  | Doc for M0.5</div><div class="xright"></div><div class="clear"><hr></hr></div></div><div id="leftColumn"><div id="navcolumn"><div id="menuAxis2_C"><h5>Axis2 C</h5><ul><li class="none"><a href="../index.html">Home</a></li><li class="expanded"><a href="../">Download Axis2 C</a><ul><li class="none"><a href="../download.cgi">M0.5 Release</a></li><li class="none"><a href="http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/c/" class="externalLink" title="External Link">Source Code</a></li></ul></li><li class="expanded"><a href="../">Documentation</a><ul><li class="none"><a href="../M0_5/index.html">Milestone 0.5</a></li></ul></li><li class="expanded"><a href="../">Get Involved</a><ul><li class="none"><a href="../mail-lists.html">Mailing Lists</a></li></ul></li><li class="expanded"><a href="../">Project Information</a><ul><li class="none"><a href="http://issues.apache.org/jira/browse/AXIS2C" class="externalLink" title="External Link">Issue Tracking</a></l
 i></ul></li></ul></div><a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy"><img alt="Built by Maven" src="../images/logos/maven-button-1.png"></img></a></div></div><div id="bodyColumn"><div class="contentBox"><div class="section"><a name="Axis2_C_User_s_Guide"></a><h2>Axis2/C User's Guide</h2><div class="subsection"><a name="-Milestone_Release_0_5"></a><h3>-Milestone Release 0.5</h3><p align="right">Pages: <a href="userguide.html">Content</a>, <a href="userguide1.html">1</a>, <b>2</b>, <a href="userguide3.html">3</a></p><p><strong>User Feedback</strong>: <a href="mailto:axis-user@ws.apache.org">axis-c-user@ws.apache.org</a>
-(Prefix
-the subject with [Axis2]). To subscribe to mailing list see <a href="../mail-lists.html">here.</a></p></div></div><div class="section"><a name="Web_Service_Clients_Using_Axis2_C"></a><h2>Web Service Clients Using Axis2/C</h2><p>Before we start looking at how to write a service clients, it's
-worth going through some background information.</p><p>Web Services can be used to provide wide range of functionality to
-the
+                	Last published: 20 March 2006
+                  | Doc for M0.5</div><div class="xright"></div><div class="clear"><hr></hr></div></div><div id="leftColumn"><div id="navcolumn"><div id="menuAxis2_C"><h5>Axis2 C</h5><ul><li class="none"><a href="../index.html">Home</a></li><li class="expanded"><a href="../">Download Axis2 C</a><ul><li class="none"><a href="../download.cgi">M0.5 Release</a></li><li class="none"><a href="http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/c/" class="externalLink" title="External Link">Source Code</a></li></ul></li><li class="expanded"><a href="../">Documentation</a><ul><li class="none"><a href="../M0_5/index.html">Milestone 0.5</a></li></ul></li><li class="expanded"><a href="../">Get Involved</a><ul><li class="none"><a href="../mail-lists.html">Mailing Lists</a></li></ul></li><li class="expanded"><a href="../">Project Information</a><ul><li class="none"><a href="http://issues.apache.org/jira/browse/AXIS2C" class="externalLink" title="External Link">Issue Tracking</a></l
 i></ul></li></ul></div><a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy"><img alt="Built by Maven" src="../images/logos/maven-button-1.png"></img></a></div></div><div id="bodyColumn"><div class="contentBox"><div class="section"><a name="Axis2_C_User_s_Guide"></a><h2>Axis2/C User's Guide</h2><div class="subsection"><a name="-Milestone_Release_0_5"></a><h3>-Milestone Release 0.5</h3><p align="right">Pages: <a href="userguide.html">Content</a>, <a href="userguide1.html">1</a>, <b>2</b>, <a href="userguide3.html">3</a></p><p><strong>User Feedback</strong>: <a href="mailto:axis-user@ws.apache.org">axis-c-user@ws.apache.org</a> (Please
+remember to prefix the subject with [Axis2]). To subscribe to mailing list
+see <a href="../mail-lists.html">here.</a></p></div></div><div class="section"><a name="Web_Service_Clients_Using_Axis2_C"></a><h2>Web Service Clients Using Axis2/C</h2><p>Before we start looking at how to write Web Service clients, it's worth
+going through some background information.</p><p>Web Services can be used to provide wide range of functionality to the
 users ranging from simple, less time consuming  operations such as
-"getStockQuote",  to time consuming business services. When we
-utilize these Web Services (invoke
-using the client applications), we cannot use some simple
-generic invocation paradigm that suites all the timing complexities
-involved
-in the service operations. For example, if we use a single transport
-channel
-(such as HTTP) to invoke a Web Service with an IN-OUT operation that
-take
-long time to complete, then most of the time we may end up with
-"connection
-time outs". On the other hand, if there are simultaneous service
-invocations
-that  we need to perform from a single client application, then
-the use of a
-"blocking" client API will degrade the performance of the client
-application.
-Similarly there are various other consequences such as One-Way
-transports
-that come in to play when we need them. Let's try to analyze some
-common
-service invocation paradigms.</p><p>Many web service engines provide the users with a Blocking and
+"getStockQuote",  to time consuming business services. When we utilize these
+Web Services (that is invoke the Web Service using a client application), we
+cannot use some simple generic invocation paradigm that suites all the timing
+complexities involved in the service operations. For example, if we use a
+single transport channel (such as HTTP) to invoke a Web Service with an
+IN-OUT operation that take long time to complete, then most of the time we
+may end up with "connection time outs". On the other hand, if there are
+simultaneous service invocations that  we need to perform from a single
+client application, then the use of a "blocking" client API will degrade the
+performance of the client application. Similarly there are various other
+consequences such as One-Way transports that come in to play when we need
+them. Let's try to analyze some common service invocation paradigms.</p><p>Many web service engines provide the users with a Blocking and
 Non-Blocking client APIs.</p><ul>
-  <li>
-    <p style="margin-bottom: 0in;"><b>Blocking API</b> -Once the
-service invocation is called, the client application hangs and only
-gets control back when the operation completes, after which client
-receives a response or a fault. This is the simplest way of invoking
-Web Services and it also suites many business situations.</p>
+  <li><p style="margin-bottom: 0in;"><b>Blocking API</b> -Once the service
+    invocation is called, the client application hangs and only gets control
+    back when the operation completes, that is when the client receives a
+    response or a fault. This is the simplest way of invoking a Web Services
+    and it also suites many common situations.</p>
   </li>
-  <li>
-    <p><b>Non-Blocking API </b>- This is a callback or polling based
-API, hence once a service invocation is called, the client application
-immediately gets the control back and the response is retrieved using
-the callback object provided. This approach provides the flexibility to
-the client application to invoke several Web Services simultaneously
-without blocking the operation already invoked.</p>
+  <li><p><b>Non-Blocking API </b>- This is a callback or polling based API,
+    hence once a service invocation is called, the client application
+    immediately gets the control back and the response is retrieved using the
+    callback object provided. This approach provides the flexibility to the
+    client application to invoke several Web Services simultaneously without
+    blocking on the operations already invoked.</p>
   </li>
-</ul><p>Both these mechanisms work in the API level. Let's name the 
-asynchronous
-behavior that we can get using the <strong>Non-Blocking API</strong>
-as
-<b>API Level Asynchrony.</b></p><p>Both these mechanisms use single transport connection to send the
-request
-and to receive the response. They severely lags the capability of using
-two
-transport connections for the request and the response (either One-Way
-of
-Two-Way). So both these mechanisms fail to address the problem of long
-running transactions (the transport connection may time-out before the
-operation completes). A possible solution would be to use <strong>two
-separate transport connections for request and response</strong>. The
-asynchronous behavior that we gain using this solution can be called
-<b>Transport Level Asynchrony</b>.</p><p>By combining API Level Asynchrony &amp; Transport Level Asynchrony
-we can
-obtain four different invocation patterns for web services as shown in
-the
+</ul><p>Both these mechanisms work in the API level. Let's name the  asynchronous
+behavior that we can get using the <strong>Non-Blocking API</strong> as
+<b>API Level Asynchrony.</b></p><p>Both these mechanisms use a single transport connection to send the
+request and to receive the response. They do not have the capability of using
+two separate transport connections, one for the request and the other for the
+response (either One-Way of Two-Way). So both these mechanisms fail to
+address the problem of long running transactions (the transport connection
+may time-out before the operation completes). A possible solution would be to
+use <strong>two separate transport connections for request and
+response</strong>. The asynchronous behavior that we gain using this solution
+can be called <b>Transport Level Asynchrony</b>.</p><p>By combining API Level Asynchrony &amp; Transport Level Asynchrony we can
+obtain four different invocation patterns for Web Services as shown in the
 following table.</p><p><a name="table1"></a><table class="bodyTable"><tbody>
-    <tr class="a"><td height="19" width="33%">
-      <p><strong>API (Blocking/Non-Blocking)</strong></p>
-      </td><td width="33%">
-      <p><strong> Dual Transports (Yes/No)</strong></p>
-      </td><td width="33%">
-      <p><strong>Description</strong></p>
+    <tr class="b"><td height="19" width="33%"><p><strong>API
+        (Blocking/Non-Blocking)</strong></p>
+      </td><td width="33%"><p><strong> Dual Transports (Yes/No)</strong></p>
+      </td><td width="33%"><p><strong>Description</strong></p>
       </td></tr>
-    <tr class="b"><td height="19" width="33%">
-      <p>Blocking</p>
-      </td><td width="33%">
-      <p>No</p>
-      </td><td width="33%">
-      <p>Simplest and the familiar invocation pattern</p>
+    <tr class="a"><td height="19" width="33%"><p>Blocking</p>
+      </td><td width="33%"><p>No</p>
+      </td><td width="33%"><p>Simplest and the familiar invocation pattern</p>
       </td></tr>
-    <tr class="a"><td height="19" width="33%">
-      <p>Non-Blocking</p>
-      </td><td width="33%">
-      <p>No</p>
-      </td><td width="33%">
-      <p>Using callbacks or polling</p>
+    <tr class="b"><td height="19" width="33%"><p>Non-Blocking</p>
+      </td><td width="33%"><p>No</p>
+      </td><td width="33%"><p>Using callbacks or polling</p>
       </td></tr>
-    <tr class="b"><td height="19" width="33%">
-      <p>Blocking</p>
-      </td><td width="33%">
-      <p>Yes</p>
-      </td><td width="33%">
-      <p>This is useful when the service operation is IN-OUT in nature
-but the transport used is One-Way (e.g. SMTP)</p>
+    <tr class="a"><td height="19" width="33%"><p>Blocking</p>
+      </td><td width="33%"><p>Yes</p>
+      </td><td width="33%"><p>This is useful when the service operation is IN-OUT
+        in nature but the transport used is One-Way (e.g. SMTP)</p>
       </td></tr>
-    <tr class="a"><td height="19" width="33%">
-      <p>Non-Blocking</p>
-      </td><td width="33%">
-      <p>Yes</p>
-      </td><td width="33%">
-      <p>This is can be used to gain the maximum asynchronous behavior.
-No blocking in the API level and also in the transport level</p>
+    <tr class="b"><td height="19" width="33%"><p>Non-Blocking</p>
+      </td><td width="33%"><p>Yes</p>
+      </td><td width="33%"><p>This is can be used to gain the maximum asynchronous
+        behavior. No blocking in the API level and also in the transport
+        level</p>
       </td></tr>
-  </tbody></table></p><p>Axis2/C is designed to provides the user with all these
-possibilities to
-invoke Web Services.</p><p>Currently we have implemented the blocking API only. The other APIs
-are being implemented.</p><div class="subsection"><a name="Writing_Web_Service_Clients_Using_Axis2_s_Primary_APIs"></a><h3>Writing Web Service Clients Using Axis2's Primary APIs</h3></div><div class="subsection"><a name="EchoBlockingClient"></a><h3>EchoBlockingClient</h3><p>Let's see how we can write a client to invoke "echoString" operation
-of "echo service" using the simplest blocking invocation. The complete
-client code with some explanation is shown below.</p>
-    <div class="source"><pre>
-int main()
-{
-    axis2_om_node_t *node = NULL;
-    axis2_om_node_t *ret_node = NULL;
-
-    axis2_status_t status = AXIS2_FAILURE;
-    axis2_char_t *client_home = NULL;
-
-    axis2_env_t *env = NULL;
-    axis2_error_t *error = NULL;
-    axis2_log_t *log = NULL;
-    axis2_allocator_t *allocator = NULL;
-
-    axis2_char_t *address = NULL;
-    axis2_char_t *wsa_action = NULL;
-
-    axis2_svc_t *svc = NULL;
-    axis2_op_t *op = NULL;
-    axis2_call_t *call = NULL;
-
-    axis2_msg_ctx_t *response_ctx = NULL;
-    axis2_msg_ctx_t *msg_ctx = NULL;
-
-    axis2_mep_client_t *mep_client = NULL;
-    axis2_msg_info_headers_t *msg_info_headers = NULL;
-    axis2_endpoint_ref_t* endpoint_ref = NULL;
-    axis2_conf_t *conf = NULL;
-    /* Having created allocator, log and error structs, create environment */
-    allocator = axis2_allocator_init (NULL);
-    error = axis2_error_create(allocator);
-    log = axis2_log_create(allocator, NULL, "addr_echo.log");
-    env = axis2_env_create_with_error_log(allocator, error, log);
-    env-&gt;log-&gt;level = AXIS2_LOG_LEVEL_TRACE;
-    axis2_error_init();
-
-
-    /* Here the client_home points to the Axis2/C standard deploy folder. The client_home can 
-     * be different from this folder. 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)
-        return;
-
-/* end point reference of echo service */
-    address = "http://localhost:9090/axis2/services/echo/echo";
-    wsa_action = "http://127.0.0.1:9090/axis2/services/echo/echoString";
-
-    /* this builds the SOAP request message using OM API.*/
-    node = build_echo_message(&amp;env);
-
-    call = axis2_call_create(&amp;env, NULL, client_home);
-    mep_client = AXIS2_CALL_GET_BASE(call, &amp;env);
-	
-    /* Add the SOAP message to Message Context and get the reference to the Message Context */
-    msg_ctx = AXIS2_MEP_CLIENT_PREPARE_SOAP_ENVELOPE(mep_client, &amp;env, node);
-	
-    /* get the reference to message info headers structure from the message context */
-    msg_info_headers = AXIS2_MSG_CTX_GET_MSG_INFO_HEADERS(msg_ctx, &amp;env);
-	
-    /* create an axis2_endpoint_ref_t struct with ERP assigned */
-    endpoint_ref = axis2_endpoint_ref_create(&amp;env, address);
-
-    /* You can set header parameters like this. Have a look at the axis2_msg_info_header.h
-     * to find out other macros available
-	 */
-    AXIS2_MSG_INFO_HEADERS_SET_TO(msg_info_headers, &amp;env, endpoint_ref);
-    AXIS2_MSG_INFO_HEADERS_SET_ACTION(msg_info_headers, &amp;env, wsa_action); 
-
-    AXIS2_CALL_SET_TO(call, &amp;env, endpoint_ref);
-
-    /* get the configuration context */
-    conf = AXIS2_CONF_CTX_GET_CONF(
-                            AXIS2_SVC_CTX_GET_CONF_CTX(
-                                AXIS2_MEP_CLIENT_GET_SVC_CTX(mep_client, &amp;env), 
-                                &amp;env), 
-                                &amp;env);
-    /* get the echo service context if it is already loaded to service context*/
-    svc = AXIS2_CONF_GET_SVC(conf, &amp;env, "echo");
-
-    if (svc)
-    {
-        op = AXIS2_SVC_GET_OP_WITH_NAME(svc, &amp;env, "echoString");
-        if (op)
-        {
-            AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, &amp;env, AXIS2_MEP_URI_OUT_IN);
-        }
-    }
-    else
-    {
-		/* echo service is not in the configuration context. We need to create the 
- 		 * operation and add it to service context. Then service context into 
-		 * configuration context
-		 */
-        axis2_qname_t *op_qname = NULL;
-        axis2_qname_t *svc_qname = axis2_qname_create(&amp;env, "echo", NULL, NULL);
-        svc = axis2_svc_create_with_qname(&amp;env, svc_qname);
-
-        op_qname = axis2_qname_create(&amp;env, "echoString", NULL, NULL);
-        op = axis2_op_create_with_qname(&amp;env, op_qname);
-        AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, &amp;env, AXIS2_MEP_URI_OUT_IN);
-        AXIS2_SVC_ADD_OP(svc, &amp;env, op);
-        AXIS2_CONF_ADD_SVC(conf, &amp;env, svc);
-    }
-
-    if (!op)
-    {
-        printf("ERROR: operation not present in service\n");
-        return -1;
-    }
-	/* Client blocks until the reply message comes. Reply message gets set
-	 * to response context.
-	 */
-    response_ctx = AXIS2_CALL_INVOKE_BLOCKING(call, &amp;env, op, msg_ctx);
-
-    if (response_ctx)
-    {
-		/* Get the response SOAP message from Response Context */
-        axis2_soap_envelope_t *soap_envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(response_ctx, &amp;env);
-        ret_node = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(soap_envelope, &amp;env);
-    }
-                                                        
-    if(ret_node)
-    {
-		/* Get the response value from the SOAP message */
-        axis2_xml_writer_t *writer = NULL;
-        axis2_om_output_t *om_output = NULL;
-        axis2_char_t *buffer = NULL;
-        
-        printf("\necho stub invoke successful!\n");
-        writer = axis2_xml_writer_create_for_memory(&amp;env, NULL, AXIS2_TRUE, 0);
-        om_output = axis2_om_output_create (&amp;env, writer);
-        AXIS2_OM_NODE_SERIALIZE (ret_node, &amp;env, om_output);
-        buffer = AXIS2_XML_WRITER_GET_XML(writer, &amp;env);
-        printf ("\nReceived OM node in XML : %s\n", buffer); 
-        AXIS2_FREE((*env)-&gt;allocator, buffer);
-    }
-    else
-    {
-        printf("echo stub invoke failed!\n");
-    }
-    
-    if (call)
-    {
-        AXIS2_CALL_FREE(call, &amp;env);
-    }
-    return status;
-}
-
-/* build SOAP request message */
-axis2_om_node_t* build_echo_message(axis2_env_t **env)
-{
-    axis2_om_node_t *echo_om_node = NULL;
-    axis2_om_element_t *echo_om_ele = NULL;
-    axis2_om_node_t* text_om_node = NULL;
-    axis2_om_element_t* text_om_ele = NULL;
-    axis2_om_namespace_t *ns1 = NULL;
-
-    ns1 = axis2_om_namespace_create (&amp;env, "http://localhost:9090/axis2/services/echo", "ns1");
-    echo_om_ele = axis2_om_element_create(&amp;env, NULL, "echoString", ns1, &amp;echo_om_node);
-    text_om_ele = axis2_om_element_create(&amp;env, echo_om_node, "text", NULL, &amp;text_om_node);
-    AXIS2_OM_ELEMENT_SET_TEXT(text_om_ele, &amp;env, "echo5", text_om_node);
-
-    return text_om_node;
-}
-
-</pre></div>
-  </div><div class="subsection"><a name="Request_SOAP_Message"></a><h3>Request SOAP Message</h3>
-    <div class="source"><pre>
-&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+  </tbody></table></p><p>Axis2/C is designed to provides the user with all these possibilities to
+invoke Web Services.</p><p>Currently we have implemented the blocking and non-blocking APIs (that is
+API level asynchrony). Support for dual transports would be implemented in
+the future.</p><div class="subsection"><a name="Writing_Web_Service_Clients_Using_Axis2_s_Primary_APIs"></a><h3>Writing Web Service Clients Using Axis2's Primary APIs</h3></div><div class="subsection"><a name="Echo_Blocking_Client"></a><h3>Echo Blocking Client</h3><p>Let's see how we can write a client to invoke "echoString" operation of
+"echo service" using the simplest blocking invocation. The complete client
+code with some explanations within comments is shown below.</p><p><font color="#008000">#include &lt;axis2_call.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_om_stax_builder.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_om_document.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_om_node.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_om_element.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_om_text.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_stream.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_log_default.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_error_default.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_xml_reader.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;stdio.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_xml_writer.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_builder.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_envelope.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_body.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_header.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_message.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_header_block.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_fault.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_fault_code.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;axis2_soap_fault_role.h&gt;<br></br>
+</font> <font color="#008000">#include &lt;platforms/axis2_platform_auto_sense.h&gt;<br></br>
+</font> <br></br>
+<font color="#000000">axis2_om_node_t</font> *<br></br>
+<font color="#000000">build_om_programatically</font>(<font color="#000000">axis2_env_t</font> **<font color="#000000">env</font>);<br></br>
+<br></br>
+<font color="#800000">int</font> <font color="#000000">main</font>(<font color="#800000">int</font> <font color="#000000">argc</font>, <font color="#800000">char</font>** <font color="#000000">argv</font>)<br></br>
+{<br></br>
+    <font color="#000000">axis2_om_node_t</font> *<font color="#000000">node</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_status_t</font> <font color="#000000">status</font> = <font color="#000000">AXIS2_FAILURE</font>;<br></br>
+    <font color="#000000">axis2_env_t</font> *<font color="#000000">env</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_error_t</font> *<font color="#000000">error</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_log_t</font> *<font color="#000000">log</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_allocator_t</font> *<font color="#000000">allocator</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_char_t</font> *<font color="#000000">address</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_char_t</font> *<font color="#000000">wsa_action</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_char_t</font> *<font color="#000000">client_home</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_om_node_t</font> *<font color="#000000">ret_node</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_svc_t</font> *<font color="#000000">svc</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_op_t</font> *<font color="#000000">op</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_call_t</font> *<font color="#000000">call</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_msg_ctx_t</font> *<font color="#000000">msg_ctx</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_mep_client_t</font> *<font color="#000000">mep_client</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_msg_info_headers_t</font> *<font color="#000000">msg_info_headers</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_endpoint_ref_t</font>* <font color="#000000">endpoint_ref</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_conf_t</font> *<font color="#000000">conf</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_msg_ctx_t</font> *<font color="#000000">response_ctx</font> = <font color="#000000">NULL</font>;<br></br>
+    <br></br>
+    <font color="#808080"><i>/* set up the environment with allocator and log*/</i></font><br></br>
+    <font color="#000000">allocator</font> = <font color="#000000">axis2_allocator_init</font> (<font color="#000000">NULL</font>);<br></br>
+    <font color="#000000">error</font> = <font color="#000000">axis2_error_create</font>(<font color="#000000">allocator</font>);<br></br>
+    <font color="#000000">log</font> = <font color="#000000">axis2_log_create</font>(<font color="#000000">allocator</font>, <font color="#000000">NULL</font>, <font color="#FF0000">"addr_echo.log"</font>);<br></br>
+    <font color="#000000">env</font> = <font color="#000000">axis2_env_create_with_error_log</font>(<font color="#000000">allocator</font>, <font color="#000000">error</font>, <font color="#000000">log</font>);<br></br>
+    <font color="#000000">env</font>-&gt;<font color="#000000">log</font>-&gt;<font color="#000000">level</font> = <font color="#000000">AXIS2_LOG_LEVEL_TRACE</font>;<br></br>
+    <font color="#000000">axis2_error_init</font>();<br></br>
+<br></br>
+    <font color="#808080"><i>/* Set up deploy folder. It is from the deploy folder, the configuration is picked up <br></br>
+     * using the axis2.xml file.<br></br>
+     * In this sample client_home points to the Axis2/C default deploy folder. The client_home can <br></br>
+     * be different from this folder on your system. For example, you may have a different folder <br></br>
+     *(say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the <br></br>
+     * modules that the client uses<br></br>
+     */</i></font><br></br>
+    <font color="#000000">client_home</font> = <font color="#000000">AXIS2_GETENV</font>(<font color="#FF0000">"AXIS2C_HOME"</font>);<br></br>
+    <font color="#000000"><b>if</b></font> (!<font color="#000000">client_home</font>)<br></br>
+        <font color="#000000">client_home</font> = <font color="#FF0000">"../../deploy"</font>;<br></br>
+    <br></br>
+    <font color="#808080"><i>/* Set end point reference of echo service */</i></font><br></br>
+    <font color="#000000">address</font> = <font color="#FF0000">"http://localhost:9090/axis2/services/echo"</font>;<br></br>
+    <font color="#000000">wsa_action</font> = <font color="#FF0000">"http://localhost:9090/axis2/services/echo/echoString"</font>;<br></br>
+    <font color="#000000"><b>if</b></font> (<font color="#000000">argc</font> &gt; <font color="#0000FF">1</font> )<br></br>
+        <font color="#000000">address</font> = <font color="#000000">argv</font>[<font color="#0000FF">1</font>];<br></br>
+    <font color="#000000"><b>if</b></font> (<font color="#000000">AXIS2_STRCMP</font>(<font color="#000000">address</font>, <font color="#FF0000">"-h"</font>) == <font color="#0000FF">0</font>)<br></br>
+    {<br></br>
+        <font color="#000000">printf</font>(<font color="#FF0000">"Usage : %s [endpoint_url]\n"</font>, <font color="#000000">argv</font>[<font color="#0000FF">0</font>]);<br></br>
+        <font color="#000000">printf</font>(<font color="#FF0000">"use -h for help\n"</font>);<br></br>
+        <font color="#000000"><b>return</b></font> <font color="#0000FF">0</font>;<br></br>
+    }<br></br>
+<br></br>
+    <font color="#000000">printf</font> (<font color="#FF0000">"Using endpoint : %s\n"</font>, <font color="#000000">address</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* build the SOAP request message content using OM API.*/</i></font><br></br>
+    <font color="#000000">node</font> = <font color="#000000">build_om_programatically</font>(&amp;<font color="#000000">env</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* create call struct */</i></font><br></br>
+    <font color="#000000">call</font> = <font color="#000000">axis2_call_create</font>(&amp;<font color="#000000">env</font>, <font color="#000000">NULL</font>, <font color="#000000">client_home</font>);<br></br>
+    <font color="#000000">mep_client</font> = <font color="#000000">AXIS2_CALL_GET_BASE</font>(<font color="#000000">call</font>, &amp;<font color="#000000">env</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* Prepare the SOAP envelope, using the SOAP message content to be sent.<br></br>
+     * Get a reference to the message context */</i></font><br></br>
+    <font color="#000000">msg_ctx</font> = <font color="#000000">AXIS2_MEP_CLIENT_PREPARE_SOAP_ENVELOPE</font>(<font color="#000000">mep_client</font>, &amp;<font color="#000000">env</font>, <font color="#000000">node</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* Get the reference to message info headers structure from the message context. <br></br>
+       This can be used to manipulate SOAP header content when using WS-Addressing. */</i></font><br></br>
+    <font color="#000000">msg_info_headers</font> = <font color="#000000">AXIS2_MSG_CTX_GET_MSG_INFO_HEADERS</font>(<font color="#000000">msg_ctx</font>, &amp;<font color="#000000">env</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* create an axis2_endpoint_ref_t struct with ERP assigned */</i></font><br></br>
+    <font color="#000000">endpoint_ref</font> = <font color="#000000">axis2_endpoint_ref_create</font>(&amp;<font color="#000000">env</font>, <font color="#000000">address</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* Set header parameters, required for WS-Addressing. <br></br>
+     * Required only if you need to make use of WS-Addressing.<br></br>
+     */</i></font><br></br>
+    <font color="#000000">AXIS2_MSG_INFO_HEADERS_SET_TO</font>(<font color="#000000">msg_info_headers</font>, &amp;<font color="#000000">env</font>, <font color="#000000">endpoint_ref</font>);<br></br>
+    <font color="#000000">AXIS2_MSG_INFO_HEADERS_SET_ACTION</font>(<font color="#000000">msg_info_headers</font>, &amp;<font color="#000000">env</font>, <font color="#000000">wsa_action</font>); <br></br>
+    <br></br>
+    <font color="#000000">AXIS2_CALL_SET_TO</font>(<font color="#000000">call</font>, &amp;<font color="#000000">env</font>, <font color="#000000">endpoint_ref</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* Get the configuration context */</i></font><br></br>
+    <font color="#000000">conf</font> = <font color="#000000">AXIS2_CONF_CTX_GET_CONF</font>(<br></br>
+                            <font color="#000000">AXIS2_SVC_CTX_GET_CONF_CTX</font>(<br></br>
+                                <font color="#000000">AXIS2_MEP_CLIENT_GET_SVC_CTX</font>(<font color="#000000">mep_client</font>, &amp;<font color="#000000">env</font>), <br></br>
+                                &amp;<font color="#000000">env</font>), <br></br>
+                                &amp;<font color="#000000">env</font>);<br></br>
+<br></br>
+    <font color="#808080"><i>/* Get the echo service context if it is already loaded to service context*/</i></font><br></br>
+    <font color="#000000">svc</font> = <font color="#000000">AXIS2_CONF_GET_SVC</font>(<font color="#000000">conf</font>, &amp;<font color="#000000">env</font>, <font color="#FF0000">"echo"</font>);<br></br>
+    <font color="#000000"><b>if</b></font> (<font color="#000000">svc</font>)<br></br>
+    {<br></br>
+        <font color="#000000">op</font> = <font color="#000000">AXIS2_SVC_GET_OP_WITH_NAME</font>(<font color="#000000">svc</font>, &amp;<font color="#000000">env</font>, <font color="#FF0000">"echoString"</font>);<br></br>
+        <font color="#000000"><b>if</b></font> (<font color="#000000">op</font>)<br></br>
+        {<br></br>
+            <font color="#000000">AXIS2_OP_SET_MSG_EXCHANGE_PATTERN</font>(<font color="#000000">op</font>, &amp;<font color="#000000">env</font>, <font color="#000000">AXIS2_MEP_URI_OUT_IN</font>);<br></br>
+        }<br></br>
+    }<br></br>
+    <font color="#000000"><b>else</b></font><br></br>
+    {<br></br>
+       <font color="#808080"><i>/* echo service is not in the configuration context. We need to create the <br></br>
+        * operation and add it to service context. Then add service context into <br></br>
+        * configuration context.<br></br>
+        */</i></font><br></br>
+        <font color="#000000">axis2_qname_t</font> *<font color="#000000">op_qname</font> = <font color="#000000">NULL</font>;<br></br>
+        <font color="#000000">axis2_qname_t</font> *<font color="#000000">svc_qname</font> = <font color="#000000">axis2_qname_create</font>(&amp;<font color="#000000">env</font>, <font color="#FF0000">"echo"</font>, <font color="#000000">NULL</font>, <font color="#000000">NULL</font>);<br></br>
+        <font color="#000000">svc</font> = <font color="#000000">axis2_svc_create_with_qname</font>(&amp;<font color="#000000">env</font>, <font color="#000000">svc_qname</font>);<br></br>
+        <font color="#000000">op_qname</font> = <font color="#000000">axis2_qname_create</font>(&amp;<font color="#000000">env</font>, <font color="#FF0000">"echoString"</font>, <font color="#000000">NULL</font>, <font color="#000000">NULL</font>);<br></br>
+        <font color="#000000">op</font> = <font color="#000000">axis2_op_create_with_qname</font>(&amp;<font color="#000000">env</font>, <font color="#000000">op_qname</font>);<br></br>
+        <font color="#000000">AXIS2_OP_SET_MSG_EXCHANGE_PATTERN</font>(<font color="#000000">op</font>, &amp;<font color="#000000">env</font>, <font color="#000000">AXIS2_MEP_URI_OUT_IN</font>);<br></br>
+        <font color="#000000">AXIS2_SVC_ADD_OP</font>(<font color="#000000">svc</font>, &amp;<font color="#000000">env</font>, <font color="#000000">op</font>);<br></br>
+        <font color="#000000">AXIS2_CONF_ADD_SVC</font>(<font color="#000000">conf</font>, &amp;<font color="#000000">env</font>, <font color="#000000">svc</font>);<br></br>
+    }<br></br>
+<br></br>
+    <font color="#000000"><b>if</b></font> (!<font color="#000000">op</font>)<br></br>
+    {<br></br>
+        <font color="#000000">printf</font>(<font color="#FF0000">"ERROR: operation not present in service\n"</font>);<br></br>
+        <font color="#000000"><b>return</b></font> -<font color="#0000FF">1</font>;<br></br>
+    }<br></br>
+<br></br>
+   <font color="#808080"><i>/* Invoke the operation. Client blocks until the response message comes. <br></br>
+    * Response message gets set in the response message context.<br></br>
+    */</i></font><br></br>
+    <font color="#000000">response_ctx</font> = <font color="#000000">AXIS2_CALL_INVOKE_BLOCKING</font>(<font color="#000000">call</font>, &amp;<font color="#000000">env</font>, <font color="#000000">op</font>, <font color="#000000">msg_ctx</font>);<br></br>
+<br></br>
+    <font color="#000000"><b>if</b></font> (<font color="#000000">response_ctx</font>)<br></br>
+    {<br></br>
+        <font color="#808080"><i>/* Get the response SOAP message from response message context */</i></font><br></br>
+        <font color="#000000">axis2_soap_envelope_t</font> *<font color="#000000">soap_envelope</font> = <font color="#000000">AXIS2_MSG_CTX_GET_SOAP_ENVELOPE</font>(<font color="#000000">response_ctx</font>, &amp;<font color="#000000">env</font>);<br></br>
+        <font color="#000000">ret_node</font> = <font color="#000000">AXIS2_SOAP_ENVELOPE_GET_BASE_NODE</font>(<font color="#000000">soap_envelope</font>, &amp;<font color="#000000">env</font>);<br></br>
+    }<br></br>
+                                                        <br></br>
+    <font color="#000000"><b>if</b></font>(<font color="#000000">ret_node</font>)<br></br>
+    {<br></br>
+        <font color="#808080"><i>/* Get the response value from the SOAP message */</i></font><br></br>
+        <font color="#000000">axis2_xml_writer_t</font> *<font color="#000000">writer</font> = <font color="#000000">NULL</font>;<br></br>
+        <font color="#000000">axis2_om_output_t</font> *<font color="#000000">om_output</font> = <font color="#000000">NULL</font>;<br></br>
+        <font color="#000000">axis2_char_t</font> *<font color="#000000">buffer</font> = <font color="#000000">NULL</font>;<br></br>
+        <br></br>
+        <font color="#000000">printf</font>(<font color="#FF0000">"\necho stub invoke SUCCESSFUL!\n"</font>);<br></br>
+        <font color="#000000">writer</font> = <font color="#000000">axis2_xml_writer_create_for_memory</font>(&amp;<font color="#000000">env</font>, <font color="#000000">NULL</font>, <font color="#000000">AXIS2_TRUE</font>, <font color="#0000FF">0</font>);<br></br>
+        <font color="#000000">om_output</font> = <font color="#000000">axis2_om_output_create</font> (&amp;<font color="#000000">env</font>, <font color="#000000">writer</font>);<br></br>
+<br></br>
+        <font color="#000000">AXIS2_OM_NODE_SERIALIZE</font> (<font color="#000000">ret_node</font>, &amp;<font color="#000000">env</font>, <font color="#000000">om_output</font>);<br></br>
+        <font color="#000000">buffer</font> = <font color="#000000">AXIS2_XML_WRITER_GET_XML</font>(<font color="#000000">writer</font>, &amp;<font color="#000000">env</font>);<br></br>
+        <font color="#000000">printf</font> (<font color="#FF0000">"\nReceived OM node in XML : %s\n"</font>, <font color="#000000">buffer</font>);<br></br>
+    }<br></br>
+    <font color="#000000"><b>else</b></font><br></br>
+    {<br></br>
+                <font color="#000000">AXIS2_LOG_ERROR</font>(<font color="#000000">env</font>-&gt;<font color="#000000">log</font>, <font color="#000000">AXIS2_LOG_SI</font>, <font color="#FF0000">"Stub invoke failed: Error code:"</font><br></br>
+                                                <font color="#FF0000">" %d :: %s"</font>, <font color="#000000">env</font>-&gt;<font color="#000000">error</font>-&gt;<font color="#000000">error_number</font>,<br></br>
+                        <font color="#000000">AXIS2_ERROR_GET_MESSAGE</font>(<font color="#000000">env</font>-&gt;<font color="#000000">error</font>));<br></br>
+        <font color="#000000">printf</font>(<font color="#FF0000">"echo stub invoke failed!\n"</font>);<br></br>
+    }<br></br>
+    <br></br>
+    <font color="#000000"><b>if</b></font> (<font color="#000000">call</font>)<br></br>
+    {<br></br>
+        <font color="#000000">AXIS2_CALL_FREE</font>(<font color="#000000">call</font>, &amp;<font color="#000000">env</font>);<br></br>
+    }<br></br>
+    <font color="#000000"><b>return</b></font> <font color="#000000">status</font>;<br></br>
+}<br></br>
+<br></br>
+<font color="#808080"><i>/* build SOAP request message content using OM */</i></font><br></br>
+<font color="#000000">axis2_om_node_t</font> *<br></br>
+<font color="#000000">build_om_programatically</font>(<font color="#000000">axis2_env_t</font> **<font color="#000000">env</font>)<br></br>
+{<br></br>
+    <font color="#000000">axis2_om_node_t</font> *<font color="#000000">echo_om_node</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_om_element_t</font>* <font color="#000000">echo_om_ele</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_om_node_t</font>* <font color="#000000">text_om_node</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_om_element_t</font> * <font color="#000000">text_om_ele</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_om_namespace_t</font> *<font color="#000000">ns1</font> = <font color="#000000">NULL</font>;<br></br>
+    <br></br>
+<br></br>
+    <font color="#000000">axis2_xml_writer_t</font> *<font color="#000000">xml_writer</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_om_output_t</font> *<font color="#000000">om_output</font> = <font color="#000000">NULL</font>;<br></br>
+    <font color="#000000">axis2_char_t</font> *<font color="#000000">buffer</font> = <font color="#000000">NULL</font>;<br></br>
+<br></br>
+    <font color="#000000">ns1</font> = <font color="#000000">axis2_om_namespace_create</font> (<font color="#000000">env</font>, <font color="#FF0000">"http://localhost:9090/axis2/services/echo"</font>, <font color="#FF0000">"ns1"</font>);<br></br>
+<br></br>
+    <font color="#000000">echo_om_ele</font> = <font color="#000000">axis2_om_element_create</font>(<font color="#000000">env</font>, <font color="#000000">NULL</font>, <font color="#FF0000">"echoString"</font>, <font color="#000000">ns1</font>, &amp;<font color="#000000">echo_om_node</font>);<br></br>
+    <br></br>
+    <font color="#000000">text_om_ele</font> = <font color="#000000">axis2_om_element_create</font>(<font color="#000000">env</font>, <font color="#000000">echo_om_node</font>, <font color="#FF0000">"text"</font>, <font color="#000000">NULL</font>, &amp;<font color="#000000">text_om_node</font>);<br></br>
+<br></br>
+    <font color="#000000">AXIS2_OM_ELEMENT_SET_TEXT</font>(<font color="#000000">text_om_ele</font>, <font color="#000000">env</font>, <font color="#FF0000">"echo5"</font>, <font color="#000000">text_om_node</font>);<br></br>
+    <br></br>
+    <br></br>
+    <font color="#000000">xml_writer</font> = <font color="#000000">axis2_xml_writer_create_for_memory</font>(<font color="#000000">env</font>, <font color="#000000">NULL</font>, <font color="#000000">AXIS2_FALSE</font>, <font color="#000000">AXIS2_FALSE</font>);<br></br>
+    <font color="#000000">om_output</font> = <font color="#000000">axis2_om_output_create</font>( <font color="#000000">env</font>, <font color="#000000">xml_writer</font>);<br></br>
+    <br></br>
+    <font color="#000000">AXIS2_OM_NODE_SERIALIZE</font>(<font color="#000000">echo_om_node</font>, <font color="#000000">env</font>, <font color="#000000">om_output</font>);<br></br>
+    <font color="#000000">buffer</font> = <font color="#000000">AXIS2_XML_WRITER_GET_XML</font>(<font color="#000000">xml_writer</font>, <font color="#000000">env</font>);         <br></br>
+    <font color="#000000">printf</font>(<font color="#FF0000">"\nSending OM node in XML : %s \n"</font>,  <font color="#000000">buffer</font>); <br></br>
+<br></br>
+    <font color="#000000"><b>return</b></font> <font color="#000000">echo_om_node</font>;<br></br>
+}<br></br>
+</p></div><div class="subsection"><a name="Request_SOAP_Message"></a><h3>Request SOAP Message</h3>
+    <div class="source"><pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
       &lt;soapenv:Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"&gt;
          &lt;wsa:To&gt;http://localhost:9090/axis2/services/echo/echo&lt;/wsa:To&gt;
@@ -301,8 +319,7 @@
 
 </pre></div>
   </div><div class="subsection"><a name="Response_SOAP_Message"></a><h3>Response SOAP Message</h3>
-    <div class="source"><pre>
-&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+    <div class="source"><pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"&gt;
       &lt;soapenv:Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"&gt;
          &lt;wsa:To&gt;http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous&lt;/wsa:To&gt;
@@ -324,7 +341,6 @@
          &lt;/ns1:echoString&gt;
       &lt;/soapenv:Body&gt;
    &lt;/soapenv:Envelope&gt;
-
 </pre></div>
   <br></br><p align="right"><a href="userguide1.html"><img src="images/arrow_left.gif" alt=""></img>
 Previous</a> | <a href="userguide3.html">Next <img src="images/arrow_right.gif" alt=""></img></a></p><p>Pages: <a href="userguide.html">Content</a>, <a href="userguide1.html">1</a>, <b>2</b>, <a href="userguide3.html">3</a></p></div></div></div></div><div class="clear"><hr></hr></div><div id="footer"><div class="xright">© 2005-2006, Apache Software Foundation</div><div class="clear"><hr></hr></div></div></body></html>