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 Stefan Hristov <sh...@gcn.bg> on 2009/07/09 17:40:46 UTC

Obtaining consumer address from Axis2/C service

Hi all,

I am writing a web-service using Axis2/C v1.6.0. The service is deployed with Apache2 mod-axis2.so.

I need to get the sender IP address (or anything which can be used to identify the consumer) when my service is called (meaning, in axis2_svc_skel_XXX_invoke function).

I have searched through the API documentation using axis2_msg_ctx_t as a reference (the startup data I have in invoke function), but unfortunately the functions I've found return my own address (the full URL, actually), not senders. I mean axis2_msg_ctx_get_from and axis2_options_get_from, both yielding axis2_endpoint_ref_t type. There are few similar other functions, but they all are returning NULL.

Any suggestions or pointers, please? :)

Re: Obtaining consumer address from Axis2/C service - SOLVED

Posted by Nabeel Naseem Ahsan <ah...@gmail.com>.
I realized that "axis2_msg_ctx_get_property " works with axis2c simple http
server. I am running apache2.

The last response to the request for fetching peer ip with apache 2 was :
"
>
> Okay, I think we can go ahead with this. The method
> axis2_apache2_worker_process_request() has access to the above data as
> well as the msg_ctx, and therefore, it can be made available, as in the
> simple axis server.
>

Please raise a Jira on this to track the fixing.

Thanks,
Samisa...
"

Can somebody please tell me with an example on how to use
axis2_apache2_worker_process_request()
call to fetch the peer ip address.

Regards,
Nabeel Ahsan

On Mon, Aug 3, 2009 at 6:03 PM, Rajika Kumarasiri <
rajika.kumarasiri@gmail.com> wrote:

> Can you send the stack trace?
>
>
> On Mon, Aug 3, 2009 at 6:17 PM, Nabeel Naseem Ahsan <
> ahsan.nabeel@gmail.com> wrote:
>
>> I tried using this property with axis2 1.5.0, but i got an segmentation
>> fault. Can anyone help me out?
>>
>> Nabeel Ahsan
>>
>>
>> On Fri, Jul 10, 2009 at 4:48 PM, Sam Carleton <sc...@gmail.com>wrote:
>>
>>> Thank you for posting the answer, this could be very useful!
>>>
>>> On Fri, Jul 10, 2009 at 7:10 AM, Stefan Hristov <sh...@gcn.bg> wrote:
>>>
>>>> Well, looking at the source usually helps :)
>>>>
>>>> There is a property in msg_ctx called AXIS2_SVR_PEER_IP_ADDR which
>>>> contains the remote peer IP address.
>>>> So basically this is how one could get the web-service consumer IP
>>>> address:
>>>>
>>>>                axutil_property_t *peer = axis2_msg_ctx_get_property
>>>> (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR);
>>>>                char *remote_ip = (char *) axutil_property_get_value
>>>> (peer, env);
>>>>                AXIS2_LOG_INFO (env->log, "Got a call from %s",
>>>> remote_ip);
>>>>
>>>> On Thursday 09 July 2009 18:40:46 Stefan Hristov wrote:
>>>> > Hi all,
>>>> >
>>>> > I am writing a web-service using Axis2/C v1.6.0. The service is
>>>> deployed with Apache2 mod-axis2.so.
>>>> >
>>>> > I need to get the sender IP address (or anything which can be used to
>>>> identify the consumer) when my service is called (meaning, in
>>>> axis2_svc_skel_XXX_invoke function).
>>>> >
>>>> > I have searched through the API documentation using axis2_msg_ctx_t as
>>>> a reference (the startup data I have in invoke function), but unfortunately
>>>> the functions I've found return my own address (the full URL, actually), not
>>>> senders. I mean axis2_msg_ctx_get_from and axis2_options_get_from, both
>>>> yielding axis2_endpoint_ref_t type. There are few similar other functions,
>>>> but they all are returning NULL.
>>>> >
>>>> > Any suggestions or pointers, please? :)
>>>> >
>>>>
>>>
>>>
>>
>
>
> --
> http://wso2.org
> http://llvm.org
> http://www.minix3.org
>

Re: Obtaining consumer address from Axis2/C service - SOLVED

Posted by Rajika Kumarasiri <ra...@gmail.com>.
Can you send the stack trace?

On Mon, Aug 3, 2009 at 6:17 PM, Nabeel Naseem Ahsan
<ah...@gmail.com>wrote:

> I tried using this property with axis2 1.5.0, but i got an segmentation
> fault. Can anyone help me out?
>
> Nabeel Ahsan
>
>
> On Fri, Jul 10, 2009 at 4:48 PM, Sam Carleton <sc...@gmail.com> wrote:
>
>> Thank you for posting the answer, this could be very useful!
>>
>> On Fri, Jul 10, 2009 at 7:10 AM, Stefan Hristov <sh...@gcn.bg> wrote:
>>
>>> Well, looking at the source usually helps :)
>>>
>>> There is a property in msg_ctx called AXIS2_SVR_PEER_IP_ADDR which
>>> contains the remote peer IP address.
>>> So basically this is how one could get the web-service consumer IP
>>> address:
>>>
>>>                axutil_property_t *peer = axis2_msg_ctx_get_property
>>> (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR);
>>>                char *remote_ip = (char *) axutil_property_get_value
>>> (peer, env);
>>>                AXIS2_LOG_INFO (env->log, "Got a call from %s",
>>> remote_ip);
>>>
>>> On Thursday 09 July 2009 18:40:46 Stefan Hristov wrote:
>>> > Hi all,
>>> >
>>> > I am writing a web-service using Axis2/C v1.6.0. The service is
>>> deployed with Apache2 mod-axis2.so.
>>> >
>>> > I need to get the sender IP address (or anything which can be used to
>>> identify the consumer) when my service is called (meaning, in
>>> axis2_svc_skel_XXX_invoke function).
>>> >
>>> > I have searched through the API documentation using axis2_msg_ctx_t as
>>> a reference (the startup data I have in invoke function), but unfortunately
>>> the functions I've found return my own address (the full URL, actually), not
>>> senders. I mean axis2_msg_ctx_get_from and axis2_options_get_from, both
>>> yielding axis2_endpoint_ref_t type. There are few similar other functions,
>>> but they all are returning NULL.
>>> >
>>> > Any suggestions or pointers, please? :)
>>> >
>>>
>>
>>
>


-- 
http://wso2.org
http://llvm.org
http://www.minix3.org

Re: Obtaining consumer address from Axis2/C service - SOLVED

Posted by Nabeel Naseem Ahsan <ah...@gmail.com>.
I tried using this property with axis2 1.5.0, but i got an segmentation
fault. Can anyone help me out?

Nabeel Ahsan

On Fri, Jul 10, 2009 at 4:48 PM, Sam Carleton <sc...@gmail.com> wrote:

> Thank you for posting the answer, this could be very useful!
>
> On Fri, Jul 10, 2009 at 7:10 AM, Stefan Hristov <sh...@gcn.bg> wrote:
>
>> Well, looking at the source usually helps :)
>>
>> There is a property in msg_ctx called AXIS2_SVR_PEER_IP_ADDR which
>> contains the remote peer IP address.
>> So basically this is how one could get the web-service consumer IP
>> address:
>>
>>                axutil_property_t *peer = axis2_msg_ctx_get_property
>> (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR);
>>                char *remote_ip = (char *) axutil_property_get_value (peer,
>> env);
>>                AXIS2_LOG_INFO (env->log, "Got a call from %s", remote_ip);
>>
>> On Thursday 09 July 2009 18:40:46 Stefan Hristov wrote:
>> > Hi all,
>> >
>> > I am writing a web-service using Axis2/C v1.6.0. The service is deployed
>> with Apache2 mod-axis2.so.
>> >
>> > I need to get the sender IP address (or anything which can be used to
>> identify the consumer) when my service is called (meaning, in
>> axis2_svc_skel_XXX_invoke function).
>> >
>> > I have searched through the API documentation using axis2_msg_ctx_t as a
>> reference (the startup data I have in invoke function), but unfortunately
>> the functions I've found return my own address (the full URL, actually), not
>> senders. I mean axis2_msg_ctx_get_from and axis2_options_get_from, both
>> yielding axis2_endpoint_ref_t type. There are few similar other functions,
>> but they all are returning NULL.
>> >
>> > Any suggestions or pointers, please? :)
>> >
>>
>
>

Re: Obtaining consumer address from Axis2/C service - SOLVED

Posted by Sam Carleton <sc...@gmail.com>.
Thank you for posting the answer, this could be very useful!

On Fri, Jul 10, 2009 at 7:10 AM, Stefan Hristov <sh...@gcn.bg> wrote:

> Well, looking at the source usually helps :)
>
> There is a property in msg_ctx called AXIS2_SVR_PEER_IP_ADDR which contains
> the remote peer IP address.
> So basically this is how one could get the web-service consumer IP address:
>
>                axutil_property_t *peer = axis2_msg_ctx_get_property
> (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR);
>                char *remote_ip = (char *) axutil_property_get_value (peer,
> env);
>                AXIS2_LOG_INFO (env->log, "Got a call from %s", remote_ip);
>
> On Thursday 09 July 2009 18:40:46 Stefan Hristov wrote:
> > Hi all,
> >
> > I am writing a web-service using Axis2/C v1.6.0. The service is deployed
> with Apache2 mod-axis2.so.
> >
> > I need to get the sender IP address (or anything which can be used to
> identify the consumer) when my service is called (meaning, in
> axis2_svc_skel_XXX_invoke function).
> >
> > I have searched through the API documentation using axis2_msg_ctx_t as a
> reference (the startup data I have in invoke function), but unfortunately
> the functions I've found return my own address (the full URL, actually), not
> senders. I mean axis2_msg_ctx_get_from and axis2_options_get_from, both
> yielding axis2_endpoint_ref_t type. There are few similar other functions,
> but they all are returning NULL.
> >
> > Any suggestions or pointers, please? :)
> >
>

Re: Obtaining consumer address from Axis2/C service - SOLVED

Posted by Stefan Hristov <sh...@gcn.bg>.
Well, looking at the source usually helps :)

There is a property in msg_ctx called AXIS2_SVR_PEER_IP_ADDR which contains the remote peer IP address. 
So basically this is how one could get the web-service consumer IP address:

                axutil_property_t *peer = axis2_msg_ctx_get_property (msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR);
                char *remote_ip = (char *) axutil_property_get_value (peer, env);
                AXIS2_LOG_INFO (env->log, "Got a call from %s", remote_ip);

On Thursday 09 July 2009 18:40:46 Stefan Hristov wrote:
> Hi all,
> 
> I am writing a web-service using Axis2/C v1.6.0. The service is deployed with Apache2 mod-axis2.so.
> 
> I need to get the sender IP address (or anything which can be used to identify the consumer) when my service is called (meaning, in axis2_svc_skel_XXX_invoke function).
> 
> I have searched through the API documentation using axis2_msg_ctx_t as a reference (the startup data I have in invoke function), but unfortunately the functions I've found return my own address (the full URL, actually), not senders. I mean axis2_msg_ctx_get_from and axis2_options_get_from, both yielding axis2_endpoint_ref_t type. There are few similar other functions, but they all are returning NULL.
> 
> Any suggestions or pointers, please? :)
>