You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by dustfinger x <du...@muddymukluk.com> on 2011/04/01 21:41:55 UTC

Questions regarding RESTful service,parameter parsing,php client

Hi,

I am brand new to the list. I sent a request to   <
c-user-info@axis.apache.org> before making this post, but there are no FAQ's
available yet. I am a newbie, so I apologize in advance to anyone that I
annoy with my amateur questions. I will present the environment that I am
working in, what I am trying to accomplish and finally a list of questions
that I hope to get answered.

Environment:
OS: 2.6.34-gentoo-r1 #2 SMP Mon Sep 13 00:17:55 MDT 2010 x86_64 Intel(R)
Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
Servers: axis2_http_server 1.6.0, www-servers/apache-2.2.16
C/C++ Compiler: sys-devel/gcc-4.4.3-r2
Web template language: dev-lang/php-5.3.5

Brief Goal Description:
To Write a RESTful service with the responsability of acting as the Data
Access Layer for an application. The service must be able to be called from
both PHP and another C++ application.

Questions:

//QUESTION 1
1. What is the cleanest way to access the values of the parameters that I am
passing to my restful service. Currently I have been calling
axiom_node_get_first_child followed by subsequent calls to
axiom_node_get_next_sibling to travers my parameter list. I was wondering if
the framework has a hash data structure that I could pass in the name of the
parameter and it would return me the value? If such a structure is not
provided by the framework, would writing one be a good approach to make my
code more maintainable? My plan would be to pass the root node to a wrapper
class and then implement a hasKey and getValue method.

//QUESTION 2
2. I am not fully clear on when to use the AXIS2_FREE method to clean up
memory. Consider the following example that comes for a GET method:

if(AXIOM_ELEMENT == nodeType){
    axis2_char_t *nodeCharText = NULL;
    nodeCharText =
static_cast<axis2_char_t*>(axiom_element_to_string(childElement,
environment, type_node));
    AXIS2_LOG_USER(environment->log, AXIS2_LOG_SI, "type_node child text of
element= [%s] ", nodeCharText);

    if(NULL != nodeCharText){
      AXIS2_FREE(environment->allocator, nodeCharText);
      nodeCharText = NULL;
    }
  }

Am I correct to call AXIS2_FREE after I am done with nodeCharText? I did not
call any create methods, but perhaps it is still my responsibility to clean
up that memory? It has not cased any faults in the application so far.

//QUESTION 3
3. Is it bad practice to use URI query parameters in a RESTLocation? for
example, is this bad practice:
<operation name="getQueryParamTest">
    <parameter name="RESTMethod">GET</parameter>
    <parameter
name="RESTLocation">query/param/type/{type}/name/{name}/test?color={color}&flavor={flavor}</parameter>
  </operation>
I know that may seem like an odd question, but I have not found any examples
of people writing axis2c services that do this. They all seem to write may
operations with all different RESTLocations instead.
4. What is the propery way of appending query parameters?
<parameter
name="RESTLocation">query/param?color={color}&flavor={flavor}</parameter>
or
<parameter
name="RESTLocation">query/param/?color={color}&flavor={flavor}</parameter>

I think that the last way leaves an empty node right before the query
parameters.

//QUESTION 4
4. What is the best way to call a RESTful service operation from PHP code?

//END QUESTIONS

Since this was my first post I was wondering if my presentation was
acceptable? Should I have posted 4 separate times, one for each question? IF
I would have broken my email up into 4 separate emails it would have been
easier to write a descriptive subject heading. Were any of my questions
dumb-questions? I have only been using axis2c actively for about a week now
and I really like it so far, but I have loads to learn and I am unsure if I
am really using it correctly.

Sincerely,
dustfinger.

Re: Questions regarding RESTful service,parameter parsing,php client

Posted by Nandika Jayawardana <ja...@gmail.com>.
You are safe to assume that the axiom tree structure is managed by the
framework. Most of the char pointers returned by the axiom structures like
element, attribute actually belong to the structure and should not be freed
unless you copied them. axiom_node_to_string is an special case where, the
entire tree from the current node is serialized and returned as an string
which needs to be freed.

In cases where you have doubts, it is best to look in to the code.

This mailing list does not have a special preference on top posting or
bottom posting. Some developers prefer to use the bottom posting though.

Regards
Nandika

On Sat, Apr 2, 2011 at 11:03 PM, dustfinger x <du...@muddymukluk.com>wrote:

> Dear Nandika,
>
> Thank you very much for answering my questions. Regarding your answer to
> question 2, I assume that I would never need to call AXIS2_FREE on node or
> element pointers that are returned from methods that traverse the tree
> structure like axiom_node_get_next_sibling for instance.
>
> 1. Am I safe to assume that the framework manages the memory for the tree
> structure and that user code must only clean up data from the tree structure
> that is returned as pointers such as axis2_char_t*?
> 2. If I am out to lunch here then what is the best way for me to know when
> I have to clean up the memory? should I just be looking at the source code
> to determine this? Again I apologize, I am fairly new to C/C++.
> 3. Does this news group prefer top or bottom posting? I see that we have
> started to top post on this thread. I know some people are very passionate
> about this subject and it does make sense to bottom post, but unfortunately
> most email clients prefer top posting, probably thanks to MS Outlook setting
> a bad standard.
>
> Sincerely,
>
> dustfinger.
>
> On Fri, Apr 1, 2011 at 11:23 PM, Nandika Jayawardana <ja...@gmail.com>wrote:
>
>> Hi dustfinger,
>>
>> Question 1
>>
>> Currently, framework does not provide a hash data structure for accessing
>> values. It was because, we wanted the service to be same for both soap and
>> rest. It would be a good approach write a wrapper class and implement hasKey
>> getValue methods.
>>
>> Question 2
>>
>> It is correct to call AXIS2_FREE after axiom_node_to_string since
>> to_string will return an allocated string.
>>
>> Regards
>> Nandika
>>
>> On Sat, Apr 2, 2011 at 1:11 AM, dustfinger x <du...@muddymukluk.com>wrote:
>>
>>> Hi,
>>>
>>> I am brand new to the list. I sent a request to   <
>>> c-user-info@axis.apache.org> before making this post, but there are no
>>> FAQ's available yet. I am a newbie, so I apologize in advance to anyone that
>>> I annoy with my amateur questions. I will present the environment that I am
>>> working in, what I am trying to accomplish and finally a list of questions
>>> that I hope to get answered.
>>>
>>> Environment:
>>> OS: 2.6.34-gentoo-r1 #2 SMP Mon Sep 13 00:17:55 MDT 2010 x86_64 Intel(R)
>>> Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
>>> Servers: axis2_http_server 1.6.0, www-servers/apache-2.2.16
>>> C/C++ Compiler: sys-devel/gcc-4.4.3-r2
>>> Web template language: dev-lang/php-5.3.5
>>>
>>> Brief Goal Description:
>>> To Write a RESTful service with the responsability of acting as the Data
>>> Access Layer for an application. The service must be able to be called from
>>> both PHP and another C++ application.
>>>
>>> Questions:
>>>
>>> //QUESTION 1
>>> 1. What is the cleanest way to access the values of the parameters that I
>>> am passing to my restful service. Currently I have been calling
>>> axiom_node_get_first_child followed by subsequent calls to
>>> axiom_node_get_next_sibling to travers my parameter list. I was wondering if
>>> the framework has a hash data structure that I could pass in the name of the
>>> parameter and it would return me the value? If such a structure is not
>>> provided by the framework, would writing one be a good approach to make my
>>> code more maintainable? My plan would be to pass the root node to a wrapper
>>> class and then implement a hasKey and getValue method.
>>>
>>> //QUESTION 2
>>> 2. I am not fully clear on when to use the AXIS2_FREE method to clean up
>>> memory. Consider the following example that comes for a GET method:
>>>
>>> if(AXIOM_ELEMENT == nodeType){
>>>     axis2_char_t *nodeCharText = NULL;
>>>     nodeCharText =
>>> static_cast<axis2_char_t*>(axiom_element_to_string(childElement,
>>> environment, type_node));
>>>     AXIS2_LOG_USER(environment->log, AXIS2_LOG_SI, "type_node child text
>>> of element= [%s] ", nodeCharText);
>>>
>>>     if(NULL != nodeCharText){
>>>       AXIS2_FREE(environment->allocator, nodeCharText);
>>>       nodeCharText = NULL;
>>>     }
>>>   }
>>>
>>> Am I correct to call AXIS2_FREE after I am done with nodeCharText? I did
>>> not call any create methods, but perhaps it is still my responsibility to
>>> clean up that memory? It has not cased any faults in the application so far.
>>>
>>> //QUESTION 3
>>> 3. Is it bad practice to use URI query parameters in a RESTLocation? for
>>> example, is this bad practice:
>>> <operation name="getQueryParamTest">
>>>     <parameter name="RESTMethod">GET</parameter>
>>>     <parameter
>>> name="RESTLocation">query/param/type/{type}/name/{name}/test?color={color}&flavor={flavor}</parameter>
>>>   </operation>
>>> I know that may seem like an odd question, but I have not found any
>>> examples of people writing axis2c services that do this. They all seem to
>>> write may operations with all different RESTLocations instead.
>>> 4. What is the propery way of appending query parameters?
>>> <parameter
>>> name="RESTLocation">query/param?color={color}&flavor={flavor}</parameter>
>>> or
>>> <parameter
>>> name="RESTLocation">query/param/?color={color}&flavor={flavor}</parameter>
>>>
>>> I think that the last way leaves an empty node right before the query
>>> parameters.
>>>
>>> //QUESTION 4
>>> 4. What is the best way to call a RESTful service operation from PHP
>>> code?
>>>
>>> //END QUESTIONS
>>>
>>> Since this was my first post I was wondering if my presentation was
>>> acceptable? Should I have posted 4 separate times, one for each question? IF
>>> I would have broken my email up into 4 separate emails it would have been
>>> easier to write a descriptive subject heading. Were any of my questions
>>> dumb-questions? I have only been using axis2c actively for about a week now
>>> and I really like it so far, but I have loads to learn and I am unsure if I
>>> am really using it correctly.
>>>
>>> Sincerely,
>>> dustfinger.
>>>
>>
>>
>

Re: Questions regarding RESTful service,parameter parsing,php client

Posted by dustfinger x <du...@muddymukluk.com>.
Dear Nandika,

Thank you very much for answering my questions. Regarding your answer to
question 2, I assume that I would never need to call AXIS2_FREE on node or
element pointers that are returned from methods that traverse the tree
structure like axiom_node_get_next_sibling for instance.

1. Am I safe to assume that the framework manages the memory for the tree
structure and that user code must only clean up data from the tree structure
that is returned as pointers such as axis2_char_t*?
2. If I am out to lunch here then what is the best way for me to know when I
have to clean up the memory? should I just be looking at the source code to
determine this? Again I apologize, I am fairly new to C/C++.
3. Does this news group prefer top or bottom posting? I see that we have
started to top post on this thread. I know some people are very passionate
about this subject and it does make sense to bottom post, but unfortunately
most email clients prefer top posting, probably thanks to MS Outlook setting
a bad standard.

Sincerely,

dustfinger.

On Fri, Apr 1, 2011 at 11:23 PM, Nandika Jayawardana <ja...@gmail.com>wrote:

> Hi dustfinger,
>
> Question 1
>
> Currently, framework does not provide a hash data structure for accessing
> values. It was because, we wanted the service to be same for both soap and
> rest. It would be a good approach write a wrapper class and implement hasKey
> getValue methods.
>
> Question 2
>
> It is correct to call AXIS2_FREE after axiom_node_to_string since to_string
> will return an allocated string.
>
> Regards
> Nandika
>
> On Sat, Apr 2, 2011 at 1:11 AM, dustfinger x <du...@muddymukluk.com>wrote:
>
>> Hi,
>>
>> I am brand new to the list. I sent a request to   <
>> c-user-info@axis.apache.org> before making this post, but there are no
>> FAQ's available yet. I am a newbie, so I apologize in advance to anyone that
>> I annoy with my amateur questions. I will present the environment that I am
>> working in, what I am trying to accomplish and finally a list of questions
>> that I hope to get answered.
>>
>> Environment:
>> OS: 2.6.34-gentoo-r1 #2 SMP Mon Sep 13 00:17:55 MDT 2010 x86_64 Intel(R)
>> Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
>> Servers: axis2_http_server 1.6.0, www-servers/apache-2.2.16
>> C/C++ Compiler: sys-devel/gcc-4.4.3-r2
>> Web template language: dev-lang/php-5.3.5
>>
>> Brief Goal Description:
>> To Write a RESTful service with the responsability of acting as the Data
>> Access Layer for an application. The service must be able to be called from
>> both PHP and another C++ application.
>>
>> Questions:
>>
>> //QUESTION 1
>> 1. What is the cleanest way to access the values of the parameters that I
>> am passing to my restful service. Currently I have been calling
>> axiom_node_get_first_child followed by subsequent calls to
>> axiom_node_get_next_sibling to travers my parameter list. I was wondering if
>> the framework has a hash data structure that I could pass in the name of the
>> parameter and it would return me the value? If such a structure is not
>> provided by the framework, would writing one be a good approach to make my
>> code more maintainable? My plan would be to pass the root node to a wrapper
>> class and then implement a hasKey and getValue method.
>>
>> //QUESTION 2
>> 2. I am not fully clear on when to use the AXIS2_FREE method to clean up
>> memory. Consider the following example that comes for a GET method:
>>
>> if(AXIOM_ELEMENT == nodeType){
>>     axis2_char_t *nodeCharText = NULL;
>>     nodeCharText =
>> static_cast<axis2_char_t*>(axiom_element_to_string(childElement,
>> environment, type_node));
>>     AXIS2_LOG_USER(environment->log, AXIS2_LOG_SI, "type_node child text
>> of element= [%s] ", nodeCharText);
>>
>>     if(NULL != nodeCharText){
>>       AXIS2_FREE(environment->allocator, nodeCharText);
>>       nodeCharText = NULL;
>>     }
>>   }
>>
>> Am I correct to call AXIS2_FREE after I am done with nodeCharText? I did
>> not call any create methods, but perhaps it is still my responsibility to
>> clean up that memory? It has not cased any faults in the application so far.
>>
>> //QUESTION 3
>> 3. Is it bad practice to use URI query parameters in a RESTLocation? for
>> example, is this bad practice:
>> <operation name="getQueryParamTest">
>>     <parameter name="RESTMethod">GET</parameter>
>>     <parameter
>> name="RESTLocation">query/param/type/{type}/name/{name}/test?color={color}&flavor={flavor}</parameter>
>>   </operation>
>> I know that may seem like an odd question, but I have not found any
>> examples of people writing axis2c services that do this. They all seem to
>> write may operations with all different RESTLocations instead.
>> 4. What is the propery way of appending query parameters?
>> <parameter
>> name="RESTLocation">query/param?color={color}&flavor={flavor}</parameter>
>> or
>> <parameter
>> name="RESTLocation">query/param/?color={color}&flavor={flavor}</parameter>
>>
>> I think that the last way leaves an empty node right before the query
>> parameters.
>>
>> //QUESTION 4
>> 4. What is the best way to call a RESTful service operation from PHP code?
>>
>> //END QUESTIONS
>>
>> Since this was my first post I was wondering if my presentation was
>> acceptable? Should I have posted 4 separate times, one for each question? IF
>> I would have broken my email up into 4 separate emails it would have been
>> easier to write a descriptive subject heading. Were any of my questions
>> dumb-questions? I have only been using axis2c actively for about a week now
>> and I really like it so far, but I have loads to learn and I am unsure if I
>> am really using it correctly.
>>
>> Sincerely,
>> dustfinger.
>>
>
>

Re: Questions regarding RESTful service,parameter parsing,php client

Posted by Nandika Jayawardana <ja...@gmail.com>.
Hi dustfinger,

Question 1

Currently, framework does not provide a hash data structure for accessing
values. It was because, we wanted the service to be same for both soap and
rest. It would be a good approach write a wrapper class and implement hasKey
getValue methods.

Question 2

It is correct to call AXIS2_FREE after axiom_node_to_string since to_string
will return an allocated string.

Regards
Nandika

On Sat, Apr 2, 2011 at 1:11 AM, dustfinger x <du...@muddymukluk.com>wrote:

> Hi,
>
> I am brand new to the list. I sent a request to   <
> c-user-info@axis.apache.org> before making this post, but there are no
> FAQ's available yet. I am a newbie, so I apologize in advance to anyone that
> I annoy with my amateur questions. I will present the environment that I am
> working in, what I am trying to accomplish and finally a list of questions
> that I hope to get answered.
>
> Environment:
> OS: 2.6.34-gentoo-r1 #2 SMP Mon Sep 13 00:17:55 MDT 2010 x86_64 Intel(R)
> Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
> Servers: axis2_http_server 1.6.0, www-servers/apache-2.2.16
> C/C++ Compiler: sys-devel/gcc-4.4.3-r2
> Web template language: dev-lang/php-5.3.5
>
> Brief Goal Description:
> To Write a RESTful service with the responsability of acting as the Data
> Access Layer for an application. The service must be able to be called from
> both PHP and another C++ application.
>
> Questions:
>
> //QUESTION 1
> 1. What is the cleanest way to access the values of the parameters that I
> am passing to my restful service. Currently I have been calling
> axiom_node_get_first_child followed by subsequent calls to
> axiom_node_get_next_sibling to travers my parameter list. I was wondering if
> the framework has a hash data structure that I could pass in the name of the
> parameter and it would return me the value? If such a structure is not
> provided by the framework, would writing one be a good approach to make my
> code more maintainable? My plan would be to pass the root node to a wrapper
> class and then implement a hasKey and getValue method.
>
> //QUESTION 2
> 2. I am not fully clear on when to use the AXIS2_FREE method to clean up
> memory. Consider the following example that comes for a GET method:
>
> if(AXIOM_ELEMENT == nodeType){
>     axis2_char_t *nodeCharText = NULL;
>     nodeCharText =
> static_cast<axis2_char_t*>(axiom_element_to_string(childElement,
> environment, type_node));
>     AXIS2_LOG_USER(environment->log, AXIS2_LOG_SI, "type_node child text of
> element= [%s] ", nodeCharText);
>
>     if(NULL != nodeCharText){
>       AXIS2_FREE(environment->allocator, nodeCharText);
>       nodeCharText = NULL;
>     }
>   }
>
> Am I correct to call AXIS2_FREE after I am done with nodeCharText? I did
> not call any create methods, but perhaps it is still my responsibility to
> clean up that memory? It has not cased any faults in the application so far.
>
> //QUESTION 3
> 3. Is it bad practice to use URI query parameters in a RESTLocation? for
> example, is this bad practice:
> <operation name="getQueryParamTest">
>     <parameter name="RESTMethod">GET</parameter>
>     <parameter
> name="RESTLocation">query/param/type/{type}/name/{name}/test?color={color}&flavor={flavor}</parameter>
>   </operation>
> I know that may seem like an odd question, but I have not found any
> examples of people writing axis2c services that do this. They all seem to
> write may operations with all different RESTLocations instead.
> 4. What is the propery way of appending query parameters?
> <parameter
> name="RESTLocation">query/param?color={color}&flavor={flavor}</parameter>
> or
> <parameter
> name="RESTLocation">query/param/?color={color}&flavor={flavor}</parameter>
>
> I think that the last way leaves an empty node right before the query
> parameters.
>
> //QUESTION 4
> 4. What is the best way to call a RESTful service operation from PHP code?
>
> //END QUESTIONS
>
> Since this was my first post I was wondering if my presentation was
> acceptable? Should I have posted 4 separate times, one for each question? IF
> I would have broken my email up into 4 separate emails it would have been
> easier to write a descriptive subject heading. Were any of my questions
> dumb-questions? I have only been using axis2c actively for about a week now
> and I really like it so far, but I have loads to learn and I am unsure if I
> am really using it correctly.
>
> Sincerely,
> dustfinger.
>

Re: Questions regarding RESTful service,parameter parsing,php client

Posted by dustfinger x <du...@muddymukluk.com>.
Thank you, your responses have been greatly appreciated.

Q1: I created my own map for parameter lookups
Q2: I have been looking at the axis2c source code for hints on whether or
not I should free memory. Sometimes I just use trial and error like Josef
suggested.
Q3: I am using URI parameters on my rest locations. I only define parameters
in this way if they are optional. Otherwise I place the parameters in the
URI path.
Q4: I am currently using cURL to make requests to my RESTful service. I am
using SimpleXML to parse the resulting XML. So far this has proven to be
very straight forward.

Sincerely,

dustfinger.

On Mon, Apr 4, 2011 at 3:29 AM, Stadelmann Josef <
josef.stadelmann@axa-winterthur.ch> wrote:

>  Potential Answer to your question 1: This is a very good idea. We use a
> payload which is a collection of named collections of elements of field-name
> field-value pairs,; and we had to code the conversion from an Axiom tree
> structure our self into several named axutil hash-table where we can access
> elements by a name to get its value.  Unfortunately this hash-table is not
> sorted among the names, and the sequence off adding hash-table entries is
> not maintained for the iterator. But it is a fast hash-table alog. Happy to
> see this as official code.
>
>
>
> Potential Answer to your Question2: Using AXIS2_FREE at the wrong time
> results in crash; in this case not using AXIS2_FREE makes your code go. So
> far we have not seen memory leaks just removing the crashing statement.
> Better once too much first. And if something like blue-magic has implicitly
> released the memory at a lower layer, i.e. like axutil or libxml or the
> like, making your code now crash when you call AXIS2_FREE, is a working fast
> approach for us.
>
>
>
> Potential Answer to your Question 4: if your Client is coded in PHP and you
> assume that your web service is implemented in Axis2/C, and you understand
> that it is isolated by some protocol, then just making your client calling
> the service should work.
>
>
>
> How to make PHP code call a C/C++ function is unknown to me as I never used
> PHP so far. In Java it would be the JNI to use (Java Native Interface) to
> call into C/C++ or have C/C++ call Java Classes. Maybe there is a similar
> thing for PHP.
>
>
>
> Josef
>
>
>
>
>
>
>
> *Von:* dustfinger x [mailto:dustfinger@muddymukluk.com]
> *Gesendet:* Freitag, 1. April 2011 21:42
> *An:* c-user@axis.apache.org
> *Betreff:* Questions regarding RESTful service,parameter parsing,php
> client
>
>
>
> Hi,
>
> I am brand new to the list. I sent a request to   <
> c-user-info@axis.apache.org> before making this post, but there are no
> FAQ's available yet. I am a newbie, so I apologize in advance to anyone that
> I annoy with my amateur questions. I will present the environment that I am
> working in, what I am trying to accomplish and finally a list of questions
> that I hope to get answered.
>
>
>
> Environment:
>
> OS: 2.6.34-gentoo-r1 #2 SMP Mon Sep 13 00:17:55 MDT 2010 x86_64 Intel(R)
> Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
> Servers: axis2_http_server 1.6.0, www-servers/apache-2.2.16
> C/C++ Compiler: sys-devel/gcc-4.4.3-r2
> Web template language: dev-lang/php-5.3.5
>
> Brief Goal Description:
> To Write a RESTful service with the responsability of acting as the Data
> Access Layer for an application. The service must be able to be called from
> both PHP and another C++ application.
>
> Questions:
>
> //QUESTION 1
> 1. What is the cleanest way to access the values of the parameters that I
> am passing to my restful service. Currently I have been calling
> axiom_node_get_first_child followed by subsequent calls to
> axiom_node_get_next_sibling to travers my parameter list. I was wondering if
> the framework has a hash data structure that I could pass in the name of the
> parameter and it would return me the value? If such a structure is not
> provided by the framework, would writing one be a good approach to make my
> code more maintainable? My plan would be to pass the root node to a wrapper
> class and then implement a hasKey and getValue method.
>
> //QUESTION 2
> 2. I am not fully clear on when to use the AXIS2_FREE method to clean up
> memory. Consider the following example that comes for a GET method:
>
> if(AXIOM_ELEMENT == nodeType){
>     axis2_char_t *nodeCharText = NULL;
>     nodeCharText =
> static_cast<axis2_char_t*>(axiom_element_to_string(childElement,
> environment, type_node));
>     AXIS2_LOG_USER(environment->log, AXIS2_LOG_SI, "type_node child text of
> element= [%s] ", nodeCharText);
>
>     if(NULL != nodeCharText){
>       AXIS2_FREE(environment->allocator, nodeCharText);
>       nodeCharText = NULL;
>     }
>   }
>
> Am I correct to call AXIS2_FREE after I am done with nodeCharText? I did
> not call any create methods, but perhaps it is still my responsibility to
> clean up that memory? It has not cased any faults in the application so far.
>
> //QUESTION 3
> 3. Is it bad practice to use URI query parameters in a RESTLocation? for
> example, is this bad practice:
> <operation name="getQueryParamTest">
>     <parameter name="RESTMethod">GET</parameter>
>     <parameter
> name="RESTLocation">query/param/type/{type}/name/{name}/test?color={color}&flavor={flavor}</parameter>
>   </operation>
> I know that may seem like an odd question, but I have not found any
> examples of people writing axis2c services that do this. They all seem to
> write may operations with all different RESTLocations instead.
> 4. What is the propery way of appending query parameters?
> <parameter
> name="RESTLocation">query/param?color={color}&flavor={flavor}</parameter>
> or
> <parameter
> name="RESTLocation">query/param/?color={color}&flavor={flavor}</parameter>
>
> I think that the last way leaves an empty node right before the query
> parameters.
>
> //QUESTION 4
> 4. What is the best way to call a RESTful service operation from PHP code?
>
> //END QUESTIONS
>
> Since this was my first post I was wondering if my presentation was
> acceptable? Should I have posted 4 separate times, one for each question? IF
> I would have broken my email up into 4 separate emails it would have been
> easier to write a descriptive subject heading. Were any of my questions
> dumb-questions? I have only been using axis2c actively for about a week now
> and I really like it so far, but I have loads to learn and I am unsure if I
> am really using it correctly.
>
> Sincerely,
> dustfinger.
>

AW: Questions regarding RESTful service,parameter parsing,php client

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
Potential Answer to your question 1: This is a very good idea. We use a
payload which is a collection of named collections of elements of
field-name field-value pairs,; and we had to code the conversion from an
Axiom tree structure our self into several named axutil hash-table where
we can access elements by a name to get its value.  Unfortunately this
hash-table is not sorted among the names, and the sequence off adding
hash-table entries is not maintained for the iterator. But it is a fast
hash-table alog. Happy to see this as official code. 

 

Potential Answer to your Question2: Using AXIS2_FREE at the wrong time
results in crash; in this case not using AXIS2_FREE makes your code go.
So far we have not seen memory leaks just removing the crashing
statement. Better once too much first. And if something like blue-magic
has implicitly released the memory at a lower layer, i.e. like axutil or
libxml or the like, making your code now crash when you call AXIS2_FREE,
is a working fast approach for us.

 

Potential Answer to your Question 4: if your Client is coded in PHP and
you assume that your web service is implemented in Axis2/C, and you
understand that it is isolated by some protocol, then just making your
client calling the service should work. 

 

How to make PHP code call a C/C++ function is unknown to me as I never
used PHP so far. In Java it would be the JNI to use (Java Native
Interface) to call into C/C++ or have C/C++ call Java Classes. Maybe
there is a similar thing for PHP.

 

Josef

 

 

 

Von: dustfinger x [mailto:dustfinger@muddymukluk.com] 
Gesendet: Freitag, 1. April 2011 21:42
An: c-user@axis.apache.org
Betreff: Questions regarding RESTful service,parameter parsing,php
client

 

Hi,

I am brand new to the list. I sent a request to
<c-...@axis.apache.org> before making this post, but there are no
FAQ's available yet. I am a newbie, so I apologize in advance to anyone
that I annoy with my amateur questions. I will present the environment
that I am working in, what I am trying to accomplish and finally a list
of questions that I hope to get answered.

 

Environment:

OS: 2.6.34-gentoo-r1 #2 SMP Mon Sep 13 00:17:55 MDT 2010 x86_64 Intel(R)
Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux
Servers: axis2_http_server 1.6.0, www-servers/apache-2.2.16
C/C++ Compiler: sys-devel/gcc-4.4.3-r2
Web template language: dev-lang/php-5.3.5

Brief Goal Description:
To Write a RESTful service with the responsability of acting as the Data
Access Layer for an application. The service must be able to be called
from both PHP and another C++ application.

Questions:

//QUESTION 1
1. What is the cleanest way to access the values of the parameters that
I am passing to my restful service. Currently I have been calling
axiom_node_get_first_child followed by subsequent calls to
axiom_node_get_next_sibling to travers my parameter list. I was
wondering if the framework has a hash data structure that I could pass
in the name of the parameter and it would return me the value? If such a
structure is not provided by the framework, would writing one be a good
approach to make my code more maintainable? My plan would be to pass the
root node to a wrapper class and then implement a hasKey and getValue
method.

//QUESTION 2
2. I am not fully clear on when to use the AXIS2_FREE method to clean up
memory. Consider the following example that comes for a GET method:

if(AXIOM_ELEMENT == nodeType){
    axis2_char_t *nodeCharText = NULL;
    nodeCharText =
static_cast<axis2_char_t*>(axiom_element_to_string(childElement,
environment, type_node));
    AXIS2_LOG_USER(environment->log, AXIS2_LOG_SI, "type_node child text
of element= [%s] ", nodeCharText);

    if(NULL != nodeCharText){
      AXIS2_FREE(environment->allocator, nodeCharText);
      nodeCharText = NULL;
    }
  }

Am I correct to call AXIS2_FREE after I am done with nodeCharText? I did
not call any create methods, but perhaps it is still my responsibility
to clean up that memory? It has not cased any faults in the application
so far.

//QUESTION 3
3. Is it bad practice to use URI query parameters in a RESTLocation? for
example, is this bad practice:
<operation name="getQueryParamTest">
    <parameter name="RESTMethod">GET</parameter>
    <parameter
name="RESTLocation">query/param/type/{type}/name/{name}/test?color={colo
r}&flavor={flavor}</parameter>
  </operation>
I know that may seem like an odd question, but I have not found any
examples of people writing axis2c services that do this. They all seem
to write may operations with all different RESTLocations instead.
4. What is the propery way of appending query parameters?
<parameter
name="RESTLocation">query/param?color={color}&flavor={flavor}</parameter
>
or
<parameter
name="RESTLocation">query/param/?color={color}&flavor={flavor}</paramete
r>

I think that the last way leaves an empty node right before the query
parameters.

//QUESTION 4
4. What is the best way to call a RESTful service operation from PHP
code?

//END QUESTIONS

Since this was my first post I was wondering if my presentation was
acceptable? Should I have posted 4 separate times, one for each
question? IF I would have broken my email up into 4 separate emails it
would have been easier to write a descriptive subject heading. Were any
of my questions dumb-questions? I have only been using axis2c actively
for about a week now and I really like it so far, but I have loads to
learn and I am unsure if I am really using it correctly.

Sincerely,
dustfinger.