Download file with in a web service and use it for furthur processing

Discussion in 'ASP .Net Web Services' started by apondu, Apr 3, 2007.

  1. apondu

    apondu Guest

    Hi,
    I am new to web services and i am facing a problem.

    I am interested in downloading some file from internet and use it for
    furthur processing For eg. i have a file at a the following URL and i
    want to download that file in the web service which i am coding and
    use it for furthur.

    In normal window application i can achieve this by the following
    code


    link : http://www2.parc.com/csl/members/woodruff/publications/1996-Woodruff-WWW5-WWW.pdf

    WebClient WC=new WebClient();

    string fileName = "c:\\" + link.Substring(link.LastIndexOf("/")+1);

    WC.DownloadFile(link,fileName);



    But if i try to achieve the same thing in web service using c#.net
    with the following code i am not able to do it.

    WebClient WC=new WebClient();

    string fileName = "c:\\" + link.Substring(link.LastIndexOf("/")+1);

    WC.DownloadFile(link,Server.MapPath(fileName));

    can some one suggest me how to achieve the it web services.I am also
    intrested in furthur performing some operation on this file for
    example reading the data from the file and use it.

    Thanks for the help.

    This is my mail-id :

    Regards,
    Govardhan
    apondu, Apr 3, 2007
    #1
    1. Advertising

  2. "apondu" <> wrote in message
    news:...
    > Hi,
    > I am new to web services and i am facing a problem.
    >
    > I am interested in downloading some file from internet and use it for
    > furthur processing For eg. i have a file at a the following URL and i
    > want to download that file in the web service which i am coding and
    > use it for furthur.
    >
    > In normal window application i can achieve this by the following
    > code
    >
    >
    > link :
    > http://www2.parc.com/csl/members/woodruff/publications/1996-Woodruff-WWW5-WWW.pdf
    >
    > WebClient WC=new WebClient();
    >
    > string fileName = "c:\\" + link.Substring(link.LastIndexOf("/")+1);
    >
    > WC.DownloadFile(link,fileName);
    >
    >
    >
    > But if i try to achieve the same thing in web service using c#.net
    > with the following code i am not able to do it.


    Could you be more specific? What problem do you have when you try it in a
    web service?

    John
    John Saunders, Apr 3, 2007
    #2
    1. Advertising

  3. apondu

    apondu Guest

    On Apr 4, 2:13 am, "John Saunders" <john.saunders at trizetto.com>
    wrote:
    > "apondu" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > > Hi,
    > > I am new towebservices and i am facing a problem.

    >
    > > I am interested indownloadingsome file from internet and use it for
    > > furthur processing For eg. i have a file at a the following URL and i
    > > want to download that file in thewebservicewhich i am coding and
    > > use it for furthur.

    >
    > > In normal window application i can achieve this by the following
    > > code

    >
    > > link :
    > >http://www2.parc.com/csl/members/woodruff/publications/1996-Woodruff-...

    >
    > > WebClient WC=new WebClient();

    >
    > > string fileName = "c:\\" + link.Substring(link.LastIndexOf("/")+1);

    >
    > > WC.DownloadFile(link,fileName);

    >
    > > But if i try to achieve the same thing inwebserviceusing c#.net
    > > with the following code i am not able to do it.

    >
    > Could you be more specific? What problem do you have when you try it in awebservice?
    >
    > John- Hide quoted text -
    >
    > - Show quoted text -


    Hi,

    I am getting a error message mentioning " HTTP 500 - Internal server
    error "
    I am doing something wrong, is it the correct procedure to achieve wht
    ai am trying to.

    Waiting for some help

    Regards,
    Govardhan
    apondu, Apr 5, 2007
    #3
  4. apondu

    Andrew Brook Guest

    Why in your WebService example do you perform a Server.MapPath on the
    absolute location of the file?
    Could you try without the Server.MapPath, and also make sure that the
    webservice has the privelages to access to the locations.

    Andrew

    "apondu" <> wrote in message
    news:...
    > On Apr 4, 2:13 am, "John Saunders" <john.saunders at trizetto.com>
    > wrote:
    >> "apondu" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >>
    >>
    >> > Hi,
    >> > I am new towebservices and i am facing a problem.

    >>
    >> > I am interested indownloadingsome file from internet and use it for
    >> > furthur processing For eg. i have a file at a the following URL and i
    >> > want to download that file in thewebservicewhich i am coding and
    >> > use it for furthur.

    >>
    >> > In normal window application i can achieve this by the following
    >> > code

    >>
    >> > link :
    >> >http://www2.parc.com/csl/members/woodruff/publications/1996-Woodruff-...

    >>
    >> > WebClient WC=new WebClient();

    >>
    >> > string fileName = "c:\\" + link.Substring(link.LastIndexOf("/")+1);

    >>
    >> > WC.DownloadFile(link,fileName);

    >>
    >> > But if i try to achieve the same thing inwebserviceusing c#.net
    >> > with the following code i am not able to do it.

    >>
    >> Could you be more specific? What problem do you have when you try it in
    >> awebservice?
    >>
    >> John- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > Hi,
    >
    > I am getting a error message mentioning " HTTP 500 - Internal server
    > error "
    > I am doing something wrong, is it the correct procedure to achieve wht
    > ai am trying to.
    >
    > Waiting for some help
    >
    > Regards,
    > Govardhan
    >
    Andrew Brook, Apr 5, 2007
    #4
  5. "apondu" <> wrote in message
    news:...
    > On Apr 4, 2:13 am, "John Saunders" <john.saunders at trizetto.com>
    > wrote:
    >> "apondu" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >>
    >>
    >> > Hi,
    >> > I am new towebservices and i am facing a problem.

    >>
    >> > I am interested indownloadingsome file from internet and use it for
    >> > furthur processing For eg. i have a file at a the following URL and i
    >> > want to download that file in thewebservicewhich i am coding and
    >> > use it for furthur.

    >>
    >> > In normal window application i can achieve this by the following
    >> > code

    >>
    >> > link :
    >> >http://www2.parc.com/csl/members/woodruff/publications/1996-Woodruff-...

    >>
    >> > WebClient WC=new WebClient();

    >>
    >> > string fileName = "c:\\" + link.Substring(link.LastIndexOf("/")+1);

    >>
    >> > WC.DownloadFile(link,fileName);

    >>
    >> > But if i try to achieve the same thing inwebserviceusing c#.net
    >> > with the following code i am not able to do it.

    >>
    >> Could you be more specific? What problem do you have when you try it in
    >> awebservice?
    >>
    >> John- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > Hi,
    >
    > I am getting a error message mentioning " HTTP 500 - Internal server
    > error "
    > I am doing something wrong, is it the correct procedure to achieve wht
    > ai am trying to.
    >
    > Waiting for some help
    >
    > Regards,
    > Govardhan


    Have you looked at this in the debugger? Please do so and tell us which .NET
    call is throwing an exception, and which exact exception. If the exception
    has InnerException set, then please report that as well (recursively).

    John
    John Saunders, Apr 5, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Taylor
    Replies:
    2
    Views:
    943
    Ryan Taylor
    Nov 10, 2004
  2. Steve C. Orr [MVP, MCSD]
    Replies:
    0
    Views:
    1,607
    Steve C. Orr [MVP, MCSD]
    Mar 7, 2005
  3. apondu
    Replies:
    1
    Views:
    378
    Patrice
    Apr 3, 2007
  4. apondu
    Replies:
    1
    Views:
    360
    Rad [Visual C# MVP]
    Apr 3, 2007
  5. Leo Violette
    Replies:
    0
    Views:
    1,020
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page