Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 14th, 2004, 12:48 PM
Registered User
 
Join Date: Jun 2004
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?

 
Old July 4th, 2004, 02:30 PM
Registered User
 
Join Date: Jun 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still looking for the answer. Anyone?

 
Old July 6th, 2004, 08:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
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
 
Old July 6th, 2004, 09:44 AM
Registered User
 
Join Date: Jun 2004
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






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.