Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Forbidden at HTTP level when using self-hosted for https and Basica Authentication

 
 
Thread Tools Display Modes
Old 03-28-2007   #1 (permalink)
wuzupgee@gmail.com
Guest


 

Forbidden at HTTP level when using self-hosted for https and Basica Authentication

Hi,
I encountered a problem when doing self-hosted web service using WCF
and hope people can help me here.
I am trying to self-host a web service, using https, and Basic
Authentication. So, I used an MSDN example at
http://msdn2.microsoft.com/en-us/library/ms733775.aspx with some
modification.
The service side configuration has this:
<wsHttpBinding>
<binding name="UsernameWithTransport">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
and the endpoint uses this configuration.

I added a custom username/password validator as described in
http://msdn2.microsoft.com/en-us/library/aa702565.aspx (but changed
the security mode to transport, since the example on MSDN is using
message). So, on the service side, extra code looks like this:

myServiceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode
=
System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
myServiceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator
= new CustomUserNameValidator();
// CustomUserNameValidator implementation here ...

On the client, I did this in the code:
client.ClientCredentials.UserName.UserName = "test1";
client.ClientCredentials.UserName.Password = "1tset";

Client side config matches the service config, so I have:
<wsHttpBinding>
<binding name="WSHttpBinding_ICalculator" >
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>

I also set the principalPermissionMode to None in the service config.

When the client invokes the service, it got the exception:
HTTP request was forbidden with client authentication scheme 'Basic'.
---> System.Net.WebException: The remote server returned an error:
(403) Forbidden.

The MSDN example is for IIS hosted. I am wondering it is doable at
all in a self-hosted service? If yes, what steps am I missiong. Here
is the whole exception stack on the client:

Unhandled Exception:
System.ServiceModel.Security.MessageSecurityException: The HTTP
request was forbidden with client authentication scheme 'Basic'. --->
System.Net.WebException: The remote server returned an error: (403)
Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply
TimeSpan timeout)
--- End of inner exception stack trace ---

Server stack trace:
at
System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest
request, HttpWebResponse response, WebException responseException,
HttpChannelFactory factory)
at
System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest
request, HttpWebResponse response, HttpChannelFactory factory,
WebException responseException)
at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message
message, TimeSpan timeout)
at
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message
message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs)
at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)

Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at SoapClient.xp_dev3.IService1.MyOperation1(String myValue)
at SoapClient.xp_dev3.Service1Client.MyOperation1(String myValue)
in :\DotNetWebService\WCFSamples\SoapClient\Service References
\xp_dev3.cs:line 119
at SoapClient.Program.Client.Main() in F:\DotNetWebService
\WCFSamples\SoapClient\Program.cs:line 25

If I set the <transport clientCredentialType="None" /> on both client
and service config, it invocation works.

Thanks in advance for any help.
Jason

 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP 403 Forbidden johnthebaptist Vista General 2 2 Weeks Ago 08:13 AM
HTTP Error 403.7 - Forbidden: SSL client certificate is required SailorDude Vista networking & sharing 0 02-22-2008 07:02 PM
Changing Default Protocol for HTTP/HTTPS Ken Vista General 0 11-10-2006 10:13 AM
How to perform an http get request from a browser hosted applicati Jens Avalon 1 04-07-2006 09:17 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50