Click here to Skip to main content
15,943,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

My asp.net system has to consume a web service on my client's server to retrieve XML data. The web service is secured by IP address so that it only returns the right result only when the consumer is from a known IP Address. I'm still developing my asp.net system, and for me to test the system, my client has my public IP address (range of IP address so that other developers can test as well) to add it to their IP address list. I can access to the web service directly from my browser. However, I'm not able to access to the web service from my asp.net code. (They redirect me to their login page right now instead of sending me XML data.) My understanding of IP address of my development (local) environment is that my asp.net system uses local host but when it reaches to the web service the web service sees my request as from my public IP address. (like localhost -> private ip address -> public ip address) Is that right? In that case, is there anything I should do in my asp.net code? Or am I thinking totally wrong?

Thank you in advance.
Posted

1 solution

If you are being redirected to a login page, that would indicate that you need authentication to access the web service.
When you connect using your browser you are allowed through because it it passing your credentials through automatically for authentication.
When you connect using your web server code, your web server will send it as an anonymous request by default. You will need to set proper credentials on the request in your code before you send it in order not to get punted to the login.
 
Share this answer
 
Comments
Espen Harlinn 15-Feb-13 9:51am    
5'ed!
fjdiewornncalwe 15-Feb-13 9:56am    
Thanks, Espen.
Meg Takahashi 15-Feb-13 9:57am    
Hi Marcus,
Thanks for your response. I did the followings and I still get the same result. Am I doing wrong?

1)
objRequest.PreAuthenticate = True
objRequest.Credentials = CredentialCache.DefaultNetworkCredentials

2)
objRequest.Credentials = New System.Net.NetworkCredential("myUserName", "myPassword", "myNetworkDomainName")

I am using GET method, but does that change anything in this situation?
fjdiewornncalwe 15-Feb-13 10:07am    
If the web service requires SOAP headers, you may want to examine this: How to: Perform Custom Authentication Using SOAP Headers
I haven't done this in a while now, so I'm a little rusty on the details.(and I'm supposed to be getting some work done...) If I get a chance I'll take a peek at some of my code where I've done this and get back to you, but it may not be for a while.
Meg Takahashi 15-Feb-13 10:10am    
Thank you Marcus! I'm gonna read the article to see if that is what I need. Thank you for your help!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900