Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 14th, 2004, 12:48 PM
Registered User
 
Join Date: Jun 2004
Location: Kortrijk, , Belgium.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing a WS in a password protected directory

Hi,

I have developed a web service in PHP using NuSOAP. I want some form of security for this WS, so I've put it in a directory which is password protected, using an htaccess file. The authentication type is Basic.

Now I'm developing a client app, written in C#, to consume this web service, but I'm having a bit of trouble to get access. I've done something similar to the example I found at MSDN (http://msdn.microsoft.com/library/de...ebservices.asp) to send the necessary credentials to the webserver:

Code:
// Create a new instance of the proxy class to an XML
// Web service method. 
MyMath.Math math = new MyMath.Math();

// Create a new instance of CredentialCache.
CredentialCache credentialCache = new CredentialCache();

// Create a new instance of NetworkCredential using the client
// credentials.
NetworkCredential credentials = new NetworkCredential(UserName,SecurelyStroredPassword,Domain);

// Add the NetworkCredential to the CredentialCache.
credentialCache.Add(new Uri(math.Url), "Basic", credentials);

// Add the CredentialCache to the proxy class credentials.
math.Credentials = credentialCache;

// Call the method on the proxy class.
int result = math.Add(3,5);
but I keep getting an "HTTP 400: Bad Request" response. I know that there must be something going wrong while sending the credentials, because when I call the web service when the password protection is off, I get the desired result.

What can I do to solve this? And is it even possible to access a directory which is protected by an htaccess file? Or can I only use this method when the webserver is running IIS?

Reply With Quote
  #2 (permalink)  
Old July 4th, 2004, 02:30 PM
Registered User
 
Join Date: Jun 2004
Location: Kortrijk, , Belgium.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still looking for the answer. Anyone?

Reply With Quote
  #3 (permalink)  
Old July 6th, 2004, 08:47 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

IIS doesn't use .htaccess files

Bad Request isn't unauthorized.. it means the request is bad.. meaning something in your request is likely malformed. Are you sure your makeing the credential call correctly? I don't know why the credentials wouldn't work- but they might not with a different webserver... I would use a sniffer to look at the packets going over the wire and see if I could figure out what was going on.


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #4 (permalink)  
Old July 6th, 2004, 09:44 AM
Registered User
 
Join Date: Jun 2004
Location: Kortrijk, , Belgium.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Heh, I've had this problem for a couple of weeks. But only half an hour after I kicked this topic back up, I found the solution . I have to send the request through a proxy server for it to work

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Protected IE mrzoab C# 2 September 7th, 2007 07:47 AM
accessing a password protected URL Tomi Java Basics 2 September 6th, 2007 11:25 AM
Password protected files southernsun VB How-To 7 August 23rd, 2007 04:53 AM
Password protected directory somnath.kartic ASP.NET 1.0 and 1.1 Basics 1 April 18th, 2006 01:49 PM
Password Protected Forums spooky012017 Dreamweaver (all versions) 4 July 24th, 2004 02:19 AM



All times are GMT -4. The time now is 11:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.