c# connecting to a web server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RazSam
    New Member
    • Aug 2007
    • 16

    c# connecting to a web server

    Hi

    Could some one help me please, i am trying to connect c# web page version 2005 to a web server where a selection of reports reside.

    Would a socket be appropiate to use, all i want to do is connect to a web server using c# and extract reports, hopefully in XML format and diaply them.

    Could some one please point me in the right direction, Is there an easier way to do all this?

    Thanks

    Raz
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by RazSam
    Hi

    Could some one help me please, i am trying to connect c# web page version 2005 to a web server where a selection of reports reside.

    Would a socket be appropiate to use, all i want to do is connect to a web server using c# and extract reports, hopefully in XML format and diaply them.

    Could some one please point me in the right direction, Is there an easier way to do all this?

    Thanks

    Raz
    I'm not quite sure what you mean by "trying to connect a c# web page ...to a web server"

    What type of application are you working on. Is it a Web Application (ASP.NET project) with C# server side code?

    Why would you be considering sockets to connect to the web server?

    Could you please describe the problem in more detail so that we can help you better.

    Thanks

    -Frinny

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      The HttpWebRequest object might be more what you are looking for, rather just a plain old socket

      Comment

      • ascendedguard
        New Member
        • Aug 2007
        • 3

        #4
        HttpWebRequest will do the trick.

        If you're reading in XML, you can get a Stream object to use with System.Xml.XmlT extReader

        For example, here's a piece of code i'm using to connect to an URL (specifically in the Digg API), and retrieve the results of the page (XML) in an XmlTextReader:

        Code:
                protected static XmlTextReader GetXmlReader(String urlString)
                {
                    System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlString);
                    request.UserAgent = _UserAgent;
        
                    System.IO.StringReader myreader;
        
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
        
                        String results = reader.ReadToEnd();
                        myreader = new System.IO.StringReader(results);
                    }
                    return new XmlTextReader(myreader);
                }

        Comment

        • RazSam
          New Member
          • Aug 2007
          • 16

          #5
          Thanks ill try that when i go back into work on Monday.

          Originally posted by ascendedguard
          HttpWebRequest will do the trick.

          If you're reading in XML, you can get a Stream object to use with System.Xml.XmlT extReader

          For example, here's a piece of code i'm using to connect to an URL (specifically in the Digg API), and retrieve the results of the page (XML) in an XmlTextReader:

          Code:
                  protected static XmlTextReader GetXmlReader(String urlString)
                  {
                      System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlString);
                      request.UserAgent = _UserAgent;
          
                      System.IO.StringReader myreader;
          
                      using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                      {
                          System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());
          
                          String results = reader.ReadToEnd();
                          myreader = new System.IO.StringReader(results);
                      }
                      return new XmlTextReader(myreader);
                  }

          Comment

          • RazSam
            New Member
            • Aug 2007
            • 16

            #6
            Hi Frinvale

            I am implementing a front end ASP.NET web application page with back end c# code. My application is trying to connect to another clients web server, in order for me to extract reports (They do not have a web service in place at the moment, though they have other web services for other purposes).

            At time intervals they place various reports on there server and in real time mode my application will connect and extract a report.

            I was a little confussed sorry thought sockets mights work, but i guess not.

            Just needed help as i am confussed. Other memebers have replied with sme good advice such as using httpwebrequest, ill try that :).

            Originally posted by Frinavale
            I'm not quite sure what you mean by "trying to connect a c# web page ...to a web server"

            What type of application are you working on. Is it a Web Application (ASP.NET project) with C# server side code?

            Why would you be considering sockets to connect to the web server?

            Could you please describe the problem in more detail so that we can help you better.

            Thanks

            -Frinny

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Originally posted by RazSam
              Hi Frinvale

              I am implementing a front end ASP.NET web application page with back end c# code. My application is trying to connect to another clients web server, in order for me to extract reports (They do not have a web service in place at the moment, though they have other web services for other purposes).

              At time intervals they place various reports on there server and in real time mode my application will connect and extract a report.

              I was a little confussed sorry thought sockets mights work, but i guess not.

              Just needed help as i am confussed. Other memebers have replied with sme good advice such as using httpwebrequest, ill try that :).
              What do you know about web services using .NET?
              Have you looked them up?

              Comment

              • RazSam
                New Member
                • Aug 2007
                • 16

                #8
                No i havent Frinvale, but i will look them up thanks

                Originally posted by Frinavale
                What do you know about web services using .NET?
                Have you looked them up?

                Comment

                Working...