axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r369350 - in /webservices/axis2/trunk/c: modules/xml/soap/soap_body.c modules/xml/soap/soap_envelope.c modules/xml/soap/soap_fault.c test/xml/soap/ test/xml/soap/soap_test.c test/xml/soap/test.xml
Date Mon, 16 Jan 2006 05:16:43 GMT
Author: nandika
Date: Sun Jan 15 21:16:31 2006
New Revision: 369350

URL: http://svn.apache.org/viewcvs?rev=369350&view=rev
Log:
soap_test added 

Added:
    webservices/axis2/trunk/c/test/xml/soap/
    webservices/axis2/trunk/c/test/xml/soap/soap_test.c
    webservices/axis2/trunk/c/test/xml/soap/test.xml
Modified:
    webservices/axis2/trunk/c/modules/xml/soap/soap_body.c
    webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c
    webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_body.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_body.c?rev=369350&r1=369349&r2=369350&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_body.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_body.c Sun Jan 15 21:16:31 2006
@@ -155,6 +155,10 @@
                         parent, env);
         }            
     }
+    if(parent_ele)
+        om_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(parent_ele, env);
+    
+    
     ele = axis2_om_element_create(env, parent, 
                                   AXIS2_SOAP_BODY_LOCAL_NAME, om_ns, 
                                   &(body_impl->om_ele_node));

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c?rev=369350&r1=369349&r2=369350&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c Sun Jan 15 21:16:31 2006
@@ -191,6 +191,7 @@
     envelope_impl->soap_version = AXIS2_SOAP12;    
     envelope_impl->header = NULL;
     envelope_impl->body = NULL;
+    envelope_impl->soap_builder =  NULL;
     
     ele = axis2_om_element_create(env, NULL, AXIS2_SOAP_ENVELOPE_LOCAL_NAME, ns, &(envelope_impl->om_ele_node));
     if (!ele)
@@ -427,10 +428,14 @@
     
     AXIS2_FUNC_PARAM_CHECK(envelope, env, NULL);
     envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    
     if(envelope_impl->body)
     {
         return envelope_impl->body;
     }
+    
+    
     envelope_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(
                         envelope_impl->om_ele_node, env);
                             
@@ -446,14 +451,14 @@
             AXIS2_SOAP_BODY_SET_BASE_NODE(envelope_impl->body, env, first_node);
             AXIS2_SOAP_BODY_SET_SOAP_VERSION(envelope_impl->body, env, envelope_impl->soap_version);
             return envelope_impl->body;
-        
         }
         else
         {
             next_node = AXIS2_OM_NODE_GET_NEXT_SIBLING(envelope_impl->om_ele_node, env);
-            while(next_node  && AXIS2_OM_NODE_GET_NODE_TYPE(envelope_impl->om_ele_node,
env) != AXIS2_OM_ELEMENT)
+         
+            while(next_node && AXIS2_OM_NODE_GET_NODE_TYPE(next_node , env) != AXIS2_OM_ELEMENT)
             {
-                next_node = AXIS2_OM_NODE_GET_NEXT_SIBLING(envelope_impl->om_ele_node,
env);
+                next_node = AXIS2_OM_NODE_GET_NEXT_SIBLING(next_node , env);
             }
             next_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(next_node, env);
             if(next_ele && AXIS2_STRCMP(AXIS2_SOAP_BODY_LOCAL_NAME, 

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c?rev=369350&r1=369349&r2=369350&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c Sun Jan 15 21:16:31 2006
@@ -236,7 +236,7 @@
     
     fault_impl->parent = body;
     
-    parent_node = AXIS2_SOAP_FAULT_GET_BASE_NODE(fault, env);
+    parent_node = AXIS2_SOAP_BODY_GET_BASE_NODE(body, env);
     
     parent_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(
                         parent_node, env);

Added: webservices/axis2/trunk/c/test/xml/soap/soap_test.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/xml/soap/soap_test.c?rev=369350&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/xml/soap/soap_test.c (added)
+++ webservices/axis2/trunk/c/test/xml/soap/soap_test.c Sun Jan 15 21:16:31 2006
@@ -0,0 +1,155 @@
+#include <axis2_om_stax_builder.h>
+#include <axis2_om_document.h>
+#include <axis2_om_node.h>
+#include <axis2_om_element.h>
+#include <axis2_om_text.h>
+#include <axis2_stream_default.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axis2_xml_reader.h>
+#include <stdio.h>
+#include <axis2_xml_writer.h>
+#include <axis2_soap_builder.h>
+#include <axis2_soap.h>
+#include <axis2_soap_envelope.h>
+#include <axis2_soap_body.h>
+#include <axis2_soap_header.h>
+#include <axis2_soap_message.h>
+#include <axis2_soap_header_block.h>
+#include <axis2_soap_fault.h>
+
+FILE *f = NULL;
+
+int read_soap(char *buffer, int size, void *ctx)
+{
+    return fread(buffer, sizeof(char), size, f); 
+}
+
+int printnode(axis2_om_node_t *om_node, axis2_env_t **env)
+{
+    axis2_om_element_t *om_ele = NULL;
+    axis2_char_t *localname = NULL;
+    AXIS2_FUNC_PARAM_CHECK(om_node, env, AXIS2_FAILURE);
+    if(AXIS2_OM_NODE_GET_NODE_TYPE(om_node, env) == AXIS2_OM_ELEMENT)
+    {
+        om_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(om_node, env);
+        localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(om_ele, env);
+        printf("\n %s \n", localname);
+    }
+}
+
+int build_soap(axis2_env_t **env, char *filename)
+{
+    axis2_om_document_t *om_doc = NULL;
+    axis2_om_stax_builder_t *om_builder = NULL;
+    axis2_xml_reader_t *xml_reader = NULL;
+    axis2_soap_builder_t *soap_builder = NULL;
+    axis2_soap_message_t *soap_message = NULL;
+    axis2_soap_envelope_t *soap_envelope = NULL;
+    axis2_om_node_t *om_node = NULL;
+    axis2_om_element_t *om_ele = NULL;
+    axis2_char_t *localname = NULL;
+    axis2_char_t *buffer = NULL;
+    axis2_xml_writer_t *xml_writer = NULL;
+    axis2_om_output_t *om_output = NULL;
+    axis2_soap_body_t *soap_body = NULL;
+    axis2_soap_header_t *soap_header = NULL;
+    
+    
+    int status = AXIS2_FALSE;
+    
+    if(!filename)
+        return -1;
+    f = fopen(filename, "r");
+    if(!f)
+        return -1;
+    
+    xml_reader = axis2_xml_reader_create_for_memory(env, read_soap, NULL, NULL);
+    
+    om_builder = axis2_om_stax_builder_create(env, xml_reader);
+    
+    om_doc = axis2_om_document_create(env, NULL, om_builder);
+    
+    soap_builder = axis2_soap_builder_create(env, om_builder, AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI);
+    if(soap_builder)    
+        printf("soap version %d", AXIS2_SOAP_BUILDER_GET_SOAP_VERSION(soap_builder, env)
);
+    soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder, env);
+          
+    om_node = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(soap_envelope, env);
+    
+    printnode(om_node, env);
+    
+    soap_header = AXIS2_SOAP_ENVELOPE_GET_HEADER(soap_envelope, env);
+    om_node = AXIS2_SOAP_HEADER_GET_BASE_NODE(soap_header, env);
+    printnode(om_node, env);
+    
+    soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+    om_node = AXIS2_SOAP_HEADER_GET_BASE_NODE(soap_body, env);
+    printnode(om_node, env);
+    
+    
+    xml_writer = axis2_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE);
+    om_output = axis2_om_output_create( env, xml_writer);  
+    AXIS2_SOAP_ENVELOPE_SERIALIZE(soap_envelope, env, om_output, AXIS2_FALSE);
+    buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);         
+    printf("%s",  buffer);
+return AXIS2_SUCCESS;
+}
+
+
+int build_soap_programatically(axis2_env_t **env)
+{
+    axis2_soap_envelope_t *soap_envelope = NULL;
+    axis2_soap_body_t *soap_body = NULL;
+    axis2_soap_header_t *soap_header = NULL;
+    axis2_soap_header_block_t *header_block = NULL;
+    axis2_soap_fault_t *soap_fault = NULL;
+    axis2_om_namespace_t *env_ns = NULL;
+    axis2_xml_writer_t *xml_writer = NULL;
+    axis2_om_output_t *om_output = NULL;
+    axis2_char_t *buffer = NULL;
+
+    env_ns = axis2_om_namespace_create(env, "http://www.w3.org/2003/05/soap-envelope", "env");
+    soap_envelope = axis2_soap_envelope_create(env, env_ns);
+    
+    soap_header = axis2_soap12_header_create_with_parent(env, soap_envelope);
+    soap_body = axis2_soap_body_create_with_parent(env, soap_envelope);
+
+    soap_fault = axis2_soap_fault_create_with_parent(env, soap_body);
+    
+    xml_writer = axis2_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE);
+    om_output = axis2_om_output_create( env, xml_writer);
+    
+    AXIS2_SOAP_ENVELOPE_SERIALIZE(soap_envelope, env, om_output, AXIS2_FALSE);
+    buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);         
+    printf("%s",  buffer);    
+    return AXIS2_SUCCESS;
+}
+
+
+int main(int argc, char *argv[])
+{
+    axis2_env_t *env = NULL;
+    axis2_allocator_t *allocator = NULL;
+    axis2_error_t *error = NULL;
+    axis2_log_t *log = NULL;
+    int i = 10;
+    char *filename = "test.xml";
+    if(argc > 1)
+        filename = argv[1];
+    allocator = axis2_allocator_init (NULL);
+    log = axis2_log_create(allocator, NULL);
+    error = axis2_error_create(allocator);
+    
+    env = axis2_env_create_with_error_log(allocator, error,  log);
+    /*i = build_soap(&env, filename); */
+    build_soap_programatically(&env);
+    getchar();
+    return 0;        
+}
+
+
+
+
+
+

Added: webservices/axis2/trunk/c/test/xml/soap/test.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/xml/soap/test.xml?rev=369350&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/xml/soap/test.xml (added)
+++ webservices/axis2/trunk/c/test/xml/soap/test.xml Sun Jan 15 21:16:31 2006
@@ -0,0 +1,58 @@
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xml="http://www.w3.org/XML/1998/namespace">
+    <env:Header>
+        <test:echoOk xmlns:test="http://example.org/ts-tests"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"
+            env:mustUnderstand="true"
+            env:anyAttribute="any value">
+            foo
+        </test:echoOk>
+        <test1:echoOk1 xmlns:test1="http://example1.org/ts-tests"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/next"
+            env:mustUnderstand="false"
+            env:anyAttribute="any value">
+            foo
+        </test1:echoOk1>
+        <test2:echoOk2 xmlns:test2="http://example2.org/ts-tests"
+            env:role="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"
+            env:mustUnderstand="1"
+            env:anyAttribute="any value">
+            foo
+        </test2:echoOk2>
+    </env:Header>
+    <env:Body>
+        <env:Fault>
+            <env:Code>
+                <env:Value>env:Sender</env:Value>
+                <env:Subcode>
+                    <env:Value>m:MessageTimeout In First Subcode</env:Value>
+                    <env:Subcode>
+                        <env:Value>m:MessageTimeout In Second Subcode</env:Value>
+                        <env:Subcode>
+                            <env:Value>m:MessageTimeout In Third Subcode</env:Value>
+                        </env:Subcode>
+                    </env:Subcode>
+                </env:Subcode>
+            </env:Code>
+            <env:Reason>
+                <env:Text xml:lang="en">Sender Timeout</env:Text>
+            </env:Reason>
+            <env:Node>
+                http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver
+            </env:Node>
+            <env:Role>
+                ultimateReceiver
+            </env:Role>
+            <env:Detail xmlns:m="http:www.sample.org">
+                Details of error
+                <m:MaxTime m:detail="This is only a test">
+                    P5M\n
+                </m:MaxTime>
+                <m:AveTime>
+                    <m:Time>
+                        P3M\n
+                    </m:Time>
+                </m:AveTime>
+            </env:Detail>
+        </env:Fault>
+    </env:Body>
+</env:Envelope>
\ No newline at end of file



Mime
View raw message