473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Choosing source IP of webservice call

Hi all,
I've been searching around for a long time to solve a question I have,
and haven't found a solution yet, hope some of you can help me.

The problem is that I have a server which has two IP addresses, and a
web application which consumes webservices from other servers. The
thing is that, in my app., I want to be able to select which IP
address, from the two possible, is used as source IP whenever I make a
call to a webservice. Is it possible?

For more information, the server is running Windows Server 2003 and the
web application is written in C#.

I hope I explained the question fine.

Thanks in advance,
Albert

May 30 '06 #1
5 1335
> thing is that, in my app., I want to be able to select which IP
address, from the two possible, is used as source IP whenever I make a
call to a webservice. Is it possible?


Just before invoking the web-method from the client, set the Url property to
whatever you want.
--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://webservices.edujini.in
-------------------
May 30 '06 #2
Thanks for the response Gaurav, but I think I didn't explain well. I
don't need to choose the url/ip of the web-method I am calling, I need
to choose from which of my local machine ips does the call come out.

Thanks again
Albert

May 31 '06 #3
using System;
using System.Web;
using System.Web.Services;

[WebService(Namespace = "urn:learnwebservices.net:samples")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService
{
[WebMethod]
public string EchoMyIPAddress()
{
return HttpContext.Current.Request.UserHostAddress.ToStri ng();
}
}

--
Kirk Allen Evans
Developer Evangelist
Microsoft Corporation
blogs.msdn.com/kaevans

=== This post provided "AS-IS" with no warranties and confers no rights ===
"berto" <be*****@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Thanks for the response Gaurav, but I think I didn't explain well. I
don't need to choose the url/ip of the web-method I am calling, I need
to choose from which of my local machine ips does the call come out.

Thanks again
Albert


May 31 '06 #4

System.Web.HttpRequest:

1. UserHostAddress (contains the IP)
2. UserHostName (contains the hostname if resolved, or IP if unresolved)

HttpRequest can be had directly from:

System.Web.HttpContext.Current.Request
HTH
--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://webservices.edujini.in
-------------------
"berto" <be*****@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Thanks for the response Gaurav, but I think I didn't explain well. I
don't need to choose the url/ip of the web-method I am calling, I need
to choose from which of my local machine ips does the call come out.

Thanks again
Albert

May 31 '06 #5
> return HttpContext.Current.Request.UserHostAddress.ToStri ng();

Oops!
Solution already provided...

btw, you don't need to do a ToString(), the property is itself a string. :-)
--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://webservices.edujini.in
-------------------
May 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Delf | last post by:
Hi all, I'm working on a solution which contains WebServices (C#), C# libraries and some unmanaged DLLs (C++). Here the layout of the calls : WebService (C#) <-> C# DLL <-> unmanaged DLL ...
1
by: Nalaka | last post by:
Hi, I am testing with Visual studio 2005, web projects. Situation: I have one solution with two web projects, created as file system projects. (I am tesing using the built in server, not IIS)...
11
by: Andy | last post by:
Make the story short, I have a VB.NET client interface calling .NET webservice, written in VB.NET as well. I am trying to make the client as thin as possible so I let the webservice part to...
3
by: Trygve Lorentzen | last post by:
Hi, I don't know if this is a stupid question, but I observe that my webservice is created for each call to a webmethod. More precisely an instance of the webservice class is created for each...
7
by: Alessandro Benedetti | last post by:
Hi. I'm calling two methods of a .NET Webservice (A) from another Webservice (B). The A Webservice is made like this: public class WSA: System.Web.Services.WebService { private int X = 0;
1
by: Ezz | last post by:
I have an interesting problem...and its one of those where I know what I want but don't know how to ask it =) I have an eCommerce application that uses Paypal for its payment gateway. It is an...
3
by: James | last post by:
Hi, I have built a windows app that makes calls to a webservice. Both webservice and windows apps are built with .net 2.0. The problem is... when I run the client Windows app on the dev machine,...
2
by: =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post by:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0. This problem can be shown when trying to access a WebService using SSL and through a proxy server after using the...
7
by: Amirallia | last post by:
Hi, I consume my webservice with the IE browser and all is ok when I call it with one browser. But when I call it a the same time with two browsers, the IE page tells me that the apllication...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.