Hi all,
I used the following codes to generate a soap message with more than one
namespaces:
ns0 = axiom_namespace_create(env,
AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, "SOAP-ENV");
ns1 = axiom_namespace_create(env,
"http://schemas.xmlsoap.org/soap/encoding/", "SOAP-ENC");
ns2 = axiom_namespace_create(env,
"http://www.w3.org/1999/XMLSchema-instance", "xsi");
ns3 = axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema",
"xsd");
ns4 = axiom_namespace_create(env, "http://stockquote", "ns1");
envelope_ele = axiom_element_create(env, NULL, "Envelope", ns0,
&envelope_node);
axiom_element_declare_namespace(envelope_ele, env, envelope_node, ns1);
axiom_element_declare_namespace(envelope_ele, env, envelope_node, ns2);
axiom_element_declare_namespace(envelope_ele, env, envelope_node, ns3);
axiom_element_declare_namespace(envelope_ele, env, envelope_node, ns4);
The generated namespace sequence is:
SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:ns1="http://stockquote">
but I want to create an exact sequence namesapce like:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:ns1="http://stockquote">
I traced the souce codes and found it uses the function
axutil_hash_find_entry(axutil_hash_t * ht,
const void *key, axis2_ssize_t klen, const void *val)
to set namespace, both including uri and prefix.
Here is the implementation of this function:
static axutil_hash_entry_t **
axutil_hash_find_entry(axutil_hash_t * ht,
const void *key, axis2_ssize_t klen, const void *val)
{
axutil_hash_entry_t **hep, *he;
unsigned int hash;
hash = ht->hash_func(key, &klen);
printf("*****************hash = %d******************", hash);
/* scan linked list */
for (hep = &ht->array[hash & ht->max], he = *hep;
he; hep = &he->next, he = *hep)
{
if (he->hash == hash
&& he->klen == klen && memcmp(he->key, key, klen) == 0)
break;
}
if (he || !val)
return hep;
/* add a new entry for non-NULL values */
printf("\n***********4**********\n");
if ((he = ht->free))
ht->free = he->next;
else
he = AXIS2_MALLOC(ht->env->allocator, sizeof(*he));
he->next = NULL;
he->hash = hash;
he->key = key;
he->klen = klen;
he->val = val;
*hep = he;
ht->count++;
printf("\n*************ht->count = %d*************\n", ht->count);
return hep;
}
I printed both hash value and count and I found the count increased by the
declare sequence. But if I used fuction "axiom_node_to_string" to see the
string format of message, I found they are not the same sequence with declaring
them. As I mentioned, I printed hash value and I didn't found any relationship
between hash value and output sequence, liking big hash value output firstly.
In my project doing now, I have to create a soap message with exact sequence
of the namespace, or it doesn't work. So I would like to know the princle of
outputing namespace and how to modify the source codes to meet my
specification, even hard coding in source codes or in the my project.
Thanks a lot.
Kelvin.Lin
---------------------------------
Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.