Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. XML / XSL
  4. is there a way to capture a server's IP address in a web service

is there a way to capture a server's IP address in a web service

Scheduled Pinned Locked Moved XML / XSL
wcfsysadminxmlquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dove11
    wrote on last edited by
    #1

    I have created a web service on our server. The client created an application to send us some information in a SOAP header. We process this information and return some values back to them. This is working fine, but we wanted to capture the client's server IP address when we record our logins. Using Request.UserHostAddress will capture the IP address from the client's computer, not from the their web server. Is this possible to do? Or would they need to pass it through a SOAP Header.

    L 1 Reply Last reply
    0
    • D dove11

      I have created a web service on our server. The client created an application to send us some information in a SOAP header. We process this information and return some values back to them. This is working fine, but we wanted to capture the client's server IP address when we record our logins. Using Request.UserHostAddress will capture the IP address from the client's computer, not from the their web server. Is this possible to do? Or would they need to pass it through a SOAP Header.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      dove11 wrote:

      I have created a web service on our server.

      What environment are you in? In .NET you can use System.Net.XXXX to obtain the machines hostname and IP. If in C++ you can use the sockets API.

      led mike

      D 1 Reply Last reply
      0
      • L led mike

        dove11 wrote:

        I have created a web service on our server.

        What environment are you in? In .NET you can use System.Net.XXXX to obtain the machines hostname and IP. If in C++ you can use the sockets API.

        led mike

        D Offline
        D Offline
        dove11
        wrote on last edited by
        #3

        Hi Mike. Thanks for replying. I am using Microsoft Development Environment 2003 Version 7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1, Microsoft Visual Basic .NET, ASP .NET. Marcy

        L 1 Reply Last reply
        0
        • D dove11

          Hi Mike. Thanks for replying. I am using Microsoft Development Environment 2003 Version 7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1, Microsoft Visual Basic .NET, ASP .NET. Marcy

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          using System.Net;

          System.Net.IPHostEntry hostent = Dns.GetHostEntry("localhost");
          foreach (IPAddress addr in hostent.AddressList)
          {
          Debug.WriteLine(String.Format("{0}:{1}", addr.Address, addr.ToString()));
          }

          led mike

          D 1 Reply Last reply
          0
          • L led mike

            using System.Net;

            System.Net.IPHostEntry hostent = Dns.GetHostEntry("localhost");
            foreach (IPAddress addr in hostent.AddressList)
            {
            Debug.WriteLine(String.Format("{0}:{1}", addr.Address, addr.ToString()));
            }

            led mike

            D Offline
            D Offline
            dove11
            wrote on last edited by
            #5

            Thanks Mike. I will try that. The server IP address I am trying to capture is a client's. This client is using our web service. We want to allow only a certain range of IP addresses access to the web service. Marcy

            L 1 Reply Last reply
            0
            • D dove11

              Thanks Mike. I will try that. The server IP address I am trying to capture is a client's. This client is using our web service. We want to allow only a certain range of IP addresses access to the web service. Marcy

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              dove11 wrote:

              The server IP address I am trying to capture is a client's.

              That is new information and not what I gave you. From your perspective the Server "is" a client. The client IP is in the HTTP Header. However the server is likely behind a firewall in which case you will only get the firewalls IP and there is nothing you can do to see behind the firewall.

              dove11 wrote:

              We want to allow only a certain range of IP addresses access to the web service.

              This is likely based "per company"? If so the firewall IP should work fine for you. http://msdn2.microsoft.com/en-us/library/system.web.httprequest.userhostaddress.aspx[^]

              dove11 wrote:

              but we wanted to capture the client's server IP address

              I missed that... my bad. In the future post ASP.NET questions in the ASP.NET forum[^], this would have been answered in about 10 minutes over there.

              led mike

              D 1 Reply Last reply
              0
              • L led mike

                dove11 wrote:

                The server IP address I am trying to capture is a client's.

                That is new information and not what I gave you. From your perspective the Server "is" a client. The client IP is in the HTTP Header. However the server is likely behind a firewall in which case you will only get the firewalls IP and there is nothing you can do to see behind the firewall.

                dove11 wrote:

                We want to allow only a certain range of IP addresses access to the web service.

                This is likely based "per company"? If so the firewall IP should work fine for you. http://msdn2.microsoft.com/en-us/library/system.web.httprequest.userhostaddress.aspx[^]

                dove11 wrote:

                but we wanted to capture the client's server IP address

                I missed that... my bad. In the future post ASP.NET questions in the ASP.NET forum[^], this would have been answered in about 10 minutes over there.

                led mike

                D Offline
                D Offline
                dove11
                wrote on last edited by
                #7

                Sorry, I wasn't sure, since it was regarding a web service and SOAP Header. I thought it would go in the XML forum. Thanks for the information. I really appreciate it.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups