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 "Ruane, Conleth" <co...@hp.com> on 2003/06/13 16:41:09 UTC
Accessing text files in SOAP service folder
Hi All.
I'm writing my first SOAP service using Apache SOAP.
I've run into a problem I can't find a solution for after a lot of searching.
I want my service to pull some settings from a text file which is in the same
folder as the service classes but if I use just the file name I get a fileNotFoundException.
I've established that the file is being looked for in the tomcat bin folder instead of the
folder where the classes are. I want to avoid using a hardcoded absolute path.
A similar problem in my jsp pages I solved using
workingDir = pageContext.getServletContext().getRealPath(request.getServletPath());
Can I do something similar in a soap service class or is there any good way to do what I want.
Thanks
Con
Re: Accessing text files in SOAP service folder
Posted by Scott Nichol <sn...@scottnichol.com>.
Doing a getRealPath is fine, but you have to code your services
specially to get the servlet context. Specifically, you must add a
parameter to the method(s) of type SOAPContext. Apache SOAP will
then pass the current request context, from which you can get the
HttpRequest, etc.
As long as you have the SOAPContext, you might want to consider
having your parameters in either the web.xml for the Apache SOAP
webapp, or the deployment descriptor for the service. These are
fairly standard places for initialization information.
If you are using a nightly build of Apache SOAP, you can also have
your service implement the ConfigurableService interface. This has a
method that is called immediately after instantiation of the service.
The method receives the webapp and deployment descriptor values as
parameters.
On 13 Jun 2003 at 16:41, Ruane, Conleth wrote:
> Hi All.
>
> I'm writing my first SOAP service using Apache SOAP.
> I've run into a problem I can't find a solution for after a lot of searching.
>
> I want my service to pull some settings from a text file which is in the same
> folder as the service classes but if I use just the file name I get a fileNotFoundException.
> I've established that the file is being looked for in the tomcat bin folder instead of the
> folder where the classes are. I want to avoid using a hardcoded absolute path.
>
> A similar problem in my jsp pages I solved using
> workingDir = pageContext.getServletContext().getRealPath(request.getServletPath());
>
> Can I do something similar in a soap service class or is there any good way to do what I want.
>
> Thanks
>
> Con
>
>
Scott Nichol
Do not reply directly to this e-mail address,
as it is filtered to only receive e-mail from
specific mailing lists.
RE: Accessing text files in SOAP service folder
Posted by "Siddharth Rath (sirath)" <si...@cisco.com>.
Hi,
You can use "ServletContext.getResource and then parse
The returned URL" to overcome this kind of issues.
Thanx
Sidd
-----Original Message-----
From: Ruane, Conleth [mailto:conleth.ruane@hp.com]
Sent: Friday, June 13, 2003 7:41 AM
To: soap-user@ws.apache.org
Subject: Accessing text files in SOAP service folder
Hi All.
I'm writing my first SOAP service using Apache SOAP.
I've run into a problem I can't find a solution for after a lot of
searching.
I want my service to pull some settings from a text file which is in the
same
folder as the service classes but if I use just the file name I get a
fileNotFoundException. I've established that the file is being looked
for in the tomcat bin folder instead of the folder where the classes
are. I want to avoid using a hardcoded absolute path.
A similar problem in my jsp pages I solved using
workingDir =
pageContext.getServletContext().getRealPath(request.getServletPath());
Can I do something similar in a soap service class or is there any good
way to do what I want.
Thanks
Con