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:
// 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
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?