Hi Dave,
In your code, you seem to be setting namespaces all over. I think one gets
over written by another.
Consider using,
ns1 = axiom_namespace_create (env,
"urn:aewebservices70",
"n");
axutil_hash_set(namespaces, "urn:aewebservices70",
AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n"));
parent_element = axiom_element_create (env, NULL, "GetItemResponse",
ns1 , &parent);
And, comment out the rest.
I believe this would solve your problem.
Regards,
Senaka
> Hi Senaka and Samisa,
>
> In my code I do this:
>
> axiom_node_t* ret_node = adb_GetItemResponse_serialize( ret_val, env,
> NULL, NULL, AXIS2_TRUE, NULL, NULL );
> adb_GetItemResponse_free( ret_val, env );
> return ret_node;
>
> The code in adb_GetItemResponse_serialize (generated code) does set the
> namespace, so it should be working but does not. Please let me know if
> there is a way for me to fix it or if axis2c code changes are needed.
>
> axiom_node_t* AXIS2_CALL
> adb_GetItemResponse_serialize(
> adb_GetItemResponse_t* _GetItemResponse,
> const axutil_env_t *env, axiom_node_t
> *parent, axiom_element_t *parent_element, int parent_tag_closed,
> axutil_hash_t *namespaces, int *next_ns_index)
> {
> axiom_node_t *current_node = NULL;
> int tag_closed = 0;
> axiom_namespace_t *ns1 = NULL;
> axis2_char_t *qname_uri = NULL;
> axis2_char_t *qname_prefix = NULL;
> axis2_char_t *p_prefix = NULL;
> axis2_bool_t ns_already_defined;
> axis2_char_t text_value_1[64];
> axis2_char_t *start_input_str = NULL;
> axis2_char_t *end_input_str = NULL;
> unsigned int start_input_str_len = 0;
> unsigned int end_input_str_len = 0;
> axiom_data_source_t *data_source = NULL;
> axutil_stream_t *stream = NULL;
> int next_ns_index_value = 0;
>
> AXIS2_ENV_CHECK(env, NULL);
> AXIS2_PARAM_CHECK(env->error, _GetItemResponse, NULL);
>
> namespaces = axutil_hash_make(env);
> next_ns_index = &next_ns_index_value;
>
> ns1 = axiom_namespace_create (env,
> "urn:aewebservices70",
> "n");
> axutil_hash_set(namespaces, "urn:aewebservices70",
> AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n"));
>
> parent_element = axiom_element_create (env, NULL, "GetItemResponse",
> ns1 , &parent);
>
> axiom_element_set_namespace(parent_element, env, ns1, parent);
>
> data_source = axiom_data_source_create(env, parent, ¤t_node);
> stream = axiom_data_source_get_stream(data_source, env);
>
> if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces,
> "urn:aewebservices70", AXIS2_HASH_KEY_STRING)))
> {
> p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof
> (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT);
> sprintf(p_prefix, "n%d", (*next_ns_index)++);
> axutil_hash_set(namespaces, "urn:aewebservices70",
> AXIS2_HASH_KEY_STRING, p_prefix);
>
>
> axiom_element_declare_namespace_assume_param_ownership(parent_element,
> env, axiom_namespace_create (env,
> "urn:aewebservices70",
> p_prefix));
> }
>
> if (!_GetItemResponse->is_valid_return)
> {
> /* no need to complain for minoccurs=0 element */
> }
> else
> {
> start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
> sizeof(axis2_char_t) *
> (4 + axutil_strlen(p_prefix) +
> axutil_strlen("return") +
> ADB_DEFAULT_DIGIT_LIMIT* 2));
>
> end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
> sizeof(axis2_char_t) *
> (5 + ADB_DEFAULT_DIGIT_LIMIT + axutil_strlen("return")));
>
> /*
> * parsing return element
> */
> sprintf(start_input_str, "<%s%sreturn",
> p_prefix?p_prefix:"",
> (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
>
> start_input_str_len = axutil_strlen(start_input_str);
> sprintf(end_input_str, "</%s%sreturn>",
> p_prefix?p_prefix:"",
> (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
> end_input_str_len = axutil_strlen(end_input_str);
>
> if(!adb_TTItem_is_particle())
> {
> axutil_stream_write(stream, env, start_input_str,
> start_input_str_len);
> }
>
> adb_TTItem_serialize(_GetItemResponse->property_return,
> env, current_node, parent_element,
> adb_TTItem_is_particle() || AXIS2_FALSE, namespaces,
> next_ns_index);
>
> if(!adb_TTItem_is_particle())
> {
> axutil_stream_write(stream, env, end_input_str,
> end_input_str_len);
> }
> }
>
> if(namespaces)
> {
> axutil_hash_index_t *hi;
> void *val;
> for (hi = axutil_hash_first(namespaces, env); hi; hi
> axutil_hash_next(env, hi))
> {
> axutil_hash_this(hi, NULL, NULL, &val);
> AXIS2_FREE(env->allocator, val);
> }
> axutil_hash_free(namespaces, env);
> }
> return parent;
> }
>
> Thanks,
>
> -Dave.
>
> -----Original Message-----
> From: Senaka Fernando [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 13, 2008 1:50 AM
> To: [email protected]
> Subject: Re: [AXIS2C] Rest - namespace on the response question
>
> Hi Dave, and Samisa,
>
> I just tried the echo_rest sample with the echo service. I see no issue
> in defining a namespace and having it sent to the other end in both
> client and server side. Thus, we would not rather need to use the
> serialize_sub_tree() method. Dave, I think you are missing something
> here.
> Take a look at samples/server/echo/echo.c build_om_programatically()
> method.
>
> Regards,
> Senaka
>
>> Hi Samisa,
>>
>> I think we use, axiom_node_serialize() as in
> http_transport_sender.c:493.
>> I will replace such occurrences with axiom_node_serialize_sub_tree().
>>
>> Regards,
>> Senaka
>>
>>> What is the method used to serialize the REST payload now? (Yes I am
>>> lazy to look into the code ;-) )
>>>
>>> There is a method serializee_sub_tree, if you use that, there would
>>> not be such problem.
>>>
>>> Samisa...
>>>
>>> Senaka Fernando wrote:
>>>> Hi Dave,
>>>>
>>>> Jolly good question. I think this may be a bug. Also, I would like
>>>> to see the response you got for your SOAP call, if it is possible.
>>>>
>>>> Regards,
>>>> Senaka
>>>>
>>>>
>>>>> Hi All,
>>>>>
>>>>> I am now using REST successfully for both GET and POST calls!
>>>>> Thanks for all the help getting this going.
>>>>>
>>>>> I have a question about the response. The nodes all have a prefix
>>>>> of "n" but no namespace is defined for "n". Shouldn't it set a
>>>>> valid namespace for "n" that matches my services namespace? I
>>>>> tried to set it myself on the return node but it didn't seem to
>>>>> work - I think I may be doing it wrong.
>>>>>
>>>>> I call the same code that I use for the SOAP calls except I pass in
>
>>>>> the itemid and userid rather than it pulling that from my request
>>>>> node.
>>>>>
>>>>> For example:
>>>>>
>>>>> http://localhost:9090/axis2/services/aewebservices70/GetItem/1000:4
>>>>> 2?use rid=joe is the URL I type into the browser.
>>>>>
>>>>> And here is the response:
>>>>>
>>>>> <n:GetItemResponse>
>>>>> <n:return>
>>>>> <n:genericItem>
>>>>> <n:itemID>1000:42</n:itemID>
>>>>> <n:itemUUID>eb2b1ea0-8343-41d5-bde7-b19601d333f3</n:itemUUID>
>>>>> <n:itemName>TSK00025</n:itemName>
>>>>> </n:genericItem>
>>>>> <n:itemType>Task</n:itemType>
>>>>> <!-- I left out the rest of the response as it is too long for
>>>>> this email -->
>>>>> </n:return>
>>>>> </n:GetItemResponse>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> -Dave.
>>>>>
>>>>> *******************************************************************
>>>>> *** This email and any files transmitted with it are confidential
>>>>> and intended solely for the use of the individual or entity to whom
>
>>>>> they are addressed.
>>>>> Any unauthorized review, use, disclosure or distribution is
>>>>> prohibited.
>>>>> If
>>>>> you are not the intended recipient, please contact the sender by
>>>>> reply e-mail and destroy all copies of the original message.
>>>>> *******************************************************************
>>>>> ***
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------
>>>>> -- To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]