Using WCF and WebProxy getting System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication sche

  • Thread starter Thread starter JimWard2014
  • Start date Start date
J

JimWard2014

Guest
I have a VS2013 Windows desktop app using target framework .NET Framework 4.5 which uses WCF to communicate with a Java server

It uses custom binding to do this and it also works using a static WebProxy provided that the Proxy Server is defined in IE11's Proxy Server LAN settings.

If a user and password are required to connect via the static proxy then my code currently works doing something like


Dim proxyCredentials As System.Net.NetworkCredential = Nothing
proxyCredentials = New System.Net.NetworkCredential(AuthenticatedProxyUser, AuthenticatedProxyPassword)
WebRequest.DefaultWebProxy.Credentials = proxyCredentials


A Customer has asked me to make it work without having to define the proxy server address and port in LAN Settings but so far I have been unable to do this. Is it possible?

In theory I should just be able to do something like

Dim proxy As WebProxy = New WebProxy(AuthenticatedProxyAddress)
proxy.Credentials = proxyCredentials
WebRequest.DefaultWebProxy = proxy

But the response I get is

System.ServiceModel.Security.MessageSecurityException:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'.
The authentication header received from the server was ''.
---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Continue reading...
 
Back
Top