You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Daniel Zhang <zh...@clinicaltools.com> on 2004/05/25 20:30:53 UTC

SOAP method to get server/ip of incoming message source

Hi, All:

In SOAP package, is there any method could retrieve servername/IP of 
incoming source?  I need a method sitting on the server side to tell the 
client servername or IP.

Thanks,

Daniel

Re: SOAP method to get server/ip of incoming message source

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Thanks Martin! Without discussion like this, it'll take me hours and 
days of time to find out those tricks.
Best,
Daniel

Martin Gainty wrote:

>Daniel-
>the suggestion gets the request from SOAPContext via
> HttpServletRequest hsr = req.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
>
>you can then get ALL of the HTTP Variable parameters that the Request has
>access to via
>hsr.getQueryString() OR
>hsr.getHost()
>to see all the HTTP Variables you have access to take a look at
>http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html
>Regards,
>-Martin
>----- Original Message ----- 
>From: "Daniel Zhang" <zh...@clinicaltools.com>
>To: <so...@ws.apache.org>
>Sent: Wednesday, May 26, 2004 9:27 AM
>Subject: Re: SOAP method to get server/ip of incoming message source
>
>
>  
>
>>Thank you Scott! That's what I want. We are using messaging API.
>>Actually I am looking at the SOAPContext class, but I didn't find method
>>to getRemoteAddr/getRemoteHost directly and I don't the trick to use
>>getProperty(Constants.BAG_HTTPSERVLETREQUEST).
>>
>>Daniel
>>
>>Scott Nichol wrote:
>>
>>    
>>
>>>You will need to access the SOAPContext for the request.  This allows you
>>>      
>>>
>to access the HttpServletRequest, on which the getRemoteAddr or
>getRemoteHost method will give you what you need.
>  
>
>>>Does your service use the RPC or messaging API?  For the messaging API,
>>>      
>>>
>you get the SOAPContext for the request passed into your service method.
>For the RPC API, you need to use a trick: add SOAPContext as the first
>parameter to your method.  For example, if your method is
>  
>
>>>   String foo(String bar, int baz)
>>>
>>>change it to
>>>
>>>   String foo(SOAPContext req, String bar, int baz)
>>>
>>>Now that you have the SOAPContext, use the getProperty method with the
>>>      
>>>
>parameter  Constants.BAG_HTTPSERVLETREQUEST, i.e.
>  
>
>>>   HttpServletRequest hsr =
>>>      
>>>
>req.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
>  
>
>>>This is documented in the User Guide
>>>      
>>>
>(http://ws.apache.org/soap/docs/guide/migration.html).
>  
>
>>>Scott Nichol
>>>
>>>Do not send e-mail directly to this e-mail address,
>>>because it is filtered to accept only mail from
>>>specific mail lists.
>>>----- Original Message ----- 
>>>From: "Daniel Zhang" <zh...@clinicaltools.com>
>>>To: <so...@ws.apache.org>
>>>Sent: Tuesday, May 25, 2004 2:30 PM
>>>Subject: SOAP method to get server/ip of incoming message source
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>Hi, All:
>>>>
>>>>In SOAP package, is there any method could retrieve servername/IP of
>>>>incoming source?  I need a method sitting on the server side to tell the
>>>>client servername or IP.
>>>>
>>>>Thanks,
>>>>
>>>>Daniel
>>>>
>>>>
>>>>
>>>>        
>>>>
>>    
>>


Re: SOAP method to get server/ip of incoming message source

Posted by Martin Gainty <mg...@hotmail.com>.
Daniel-
the suggestion gets the request from SOAPContext via
 HttpServletRequest hsr = req.getProperty(Constants.BAG_HTTPSERVLETREQUEST);

you can then get ALL of the HTTP Variable parameters that the Request has
access to via
hsr.getQueryString() OR
hsr.getHost()
to see all the HTTP Variables you have access to take a look at
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html
Regards,
-Martin
----- Original Message ----- 
From: "Daniel Zhang" <zh...@clinicaltools.com>
To: <so...@ws.apache.org>
Sent: Wednesday, May 26, 2004 9:27 AM
Subject: Re: SOAP method to get server/ip of incoming message source


> Thank you Scott! That's what I want. We are using messaging API.
> Actually I am looking at the SOAPContext class, but I didn't find method
> to getRemoteAddr/getRemoteHost directly and I don't the trick to use
> getProperty(Constants.BAG_HTTPSERVLETREQUEST).
>
> Daniel
>
> Scott Nichol wrote:
>
> >You will need to access the SOAPContext for the request.  This allows you
to access the HttpServletRequest, on which the getRemoteAddr or
getRemoteHost method will give you what you need.
> >
> >Does your service use the RPC or messaging API?  For the messaging API,
you get the SOAPContext for the request passed into your service method.
For the RPC API, you need to use a trick: add SOAPContext as the first
parameter to your method.  For example, if your method is
> >
> >    String foo(String bar, int baz)
> >
> >change it to
> >
> >    String foo(SOAPContext req, String bar, int baz)
> >
> >Now that you have the SOAPContext, use the getProperty method with the
parameter  Constants.BAG_HTTPSERVLETREQUEST, i.e.
> >
> >    HttpServletRequest hsr =
req.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
> >
> >This is documented in the User Guide
(http://ws.apache.org/soap/docs/guide/migration.html).
> >
> >Scott Nichol
> >
> >Do not send e-mail directly to this e-mail address,
> >because it is filtered to accept only mail from
> >specific mail lists.
> >----- Original Message ----- 
> >From: "Daniel Zhang" <zh...@clinicaltools.com>
> >To: <so...@ws.apache.org>
> >Sent: Tuesday, May 25, 2004 2:30 PM
> >Subject: SOAP method to get server/ip of incoming message source
> >
> >
> >
> >
> >>Hi, All:
> >>
> >>In SOAP package, is there any method could retrieve servername/IP of
> >>incoming source?  I need a method sitting on the server side to tell the
> >>client servername or IP.
> >>
> >>Thanks,
> >>
> >>Daniel
> >>
> >>
> >>
>
>

Re: SOAP method to get server/ip of incoming message source

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Thank you Scott! That's what I want. We are using messaging API.  
Actually I am looking at the SOAPContext class, but I didn't find method 
to getRemoteAddr/getRemoteHost directly and I don't the trick to use 
getProperty(Constants.BAG_HTTPSERVLETREQUEST).

Daniel

Scott Nichol wrote:

>You will need to access the SOAPContext for the request.  This allows you to access the HttpServletRequest, on which the getRemoteAddr or getRemoteHost method will give you what you need.
>
>Does your service use the RPC or messaging API?  For the messaging API, you get the SOAPContext for the request passed into your service method.  For the RPC API, you need to use a trick: add SOAPContext as the first parameter to your method.  For example, if your method is
>
>    String foo(String bar, int baz)
>
>change it to
>
>    String foo(SOAPContext req, String bar, int baz)
>
>Now that you have the SOAPContext, use the getProperty method with the parameter  Constants.BAG_HTTPSERVLETREQUEST, i.e.
>
>    HttpServletRequest hsr = req.getProperty(Constants.BAG_HTTPSERVLETREQUEST);
>
>This is documented in the User Guide (http://ws.apache.org/soap/docs/guide/migration.html).
>
>Scott Nichol
>
>Do not send e-mail directly to this e-mail address,
>because it is filtered to accept only mail from
>specific mail lists.
>----- Original Message ----- 
>From: "Daniel Zhang" <zh...@clinicaltools.com>
>To: <so...@ws.apache.org>
>Sent: Tuesday, May 25, 2004 2:30 PM
>Subject: SOAP method to get server/ip of incoming message source
>
>
>  
>
>>Hi, All:
>>
>>In SOAP package, is there any method could retrieve servername/IP of 
>>incoming source?  I need a method sitting on the server side to tell the 
>>client servername or IP.
>>
>>Thanks,
>>
>>Daniel
>>
>>    
>>


Re: SOAP method to get server/ip of incoming message source

Posted by Scott Nichol <sn...@scottnichol.com>.
You will need to access the SOAPContext for the request.  This allows you to access the HttpServletRequest, on which the getRemoteAddr or getRemoteHost method will give you what you need.

Does your service use the RPC or messaging API?  For the messaging API, you get the SOAPContext for the request passed into your service method.  For the RPC API, you need to use a trick: add SOAPContext as the first parameter to your method.  For example, if your method is

    String foo(String bar, int baz)

change it to

    String foo(SOAPContext req, String bar, int baz)

Now that you have the SOAPContext, use the getProperty method with the parameter  Constants.BAG_HTTPSERVLETREQUEST, i.e.

    HttpServletRequest hsr = req.getProperty(Constants.BAG_HTTPSERVLETREQUEST);

This is documented in the User Guide (http://ws.apache.org/soap/docs/guide/migration.html).

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "Daniel Zhang" <zh...@clinicaltools.com>
To: <so...@ws.apache.org>
Sent: Tuesday, May 25, 2004 2:30 PM
Subject: SOAP method to get server/ip of incoming message source


> Hi, All:
> 
> In SOAP package, is there any method could retrieve servername/IP of 
> incoming source?  I need a method sitting on the server side to tell the 
> client servername or IP.
> 
> Thanks,
> 
> Daniel
> 

Re: SOAP method to get server/ip of incoming message source

Posted by Daniel Zhang <zh...@clinicaltools.com>.
Martin:

The method you are talking about is the client side.  And we have no 
control of our partners(clients) side. We only know our clients sending 
us SOAP message and we(server side) need to tell the URLs/IPs of our 
clients.

Daniel
mail.laconiadatasystems.com wrote:

>Daniel-
>
>>>From the URL you can get your QueryString e.g.
>
>  URL url = new URL ("http://www.mySoapRouter.com/soap/servlet/rpcrouter");
>  Response resp = call.invoke (url, "");
>
>  string query=url.getQuery();
>  string host = url.getHost();
>  /*and most anything else you need can be extracted from the url*/
>  HTH,
>  Martin
>----- Original Message ----- 
>From: "Daniel Zhang" <zh...@clinicaltools.com>
>To: <so...@ws.apache.org>
>Sent: Tuesday, May 25, 2004 2:30 PM
>Subject: SOAP method to get server/ip of incoming message source
>
>
>  
>
>>Hi, All:
>>
>>In SOAP package, is there any method could retrieve servername/IP of
>>incoming source?  I need a method sitting on the server side to tell the
>>client servername or IP.
>>
>>Thanks,
>>
>>Daniel
>>
>>    
>>