ASP.NET webservice - calling from .NET 4.0
Posted on 2013-01-02
I am trying to call a web service which is a non WCF service (its compiled in .NET4 but uses the older .NET2 protocols)
Dim sURL As String = txtURL.Text
c = New ServiceReference1.WebServiceSoapClient("WebServiceSoap", sURL.Trim.TrimEnd("/"c) & "/webservice.asmx")
This works but when I try to consume it it comes up with the errors:
The client certificate is not provided. Specify a client certificate in ClientCredentials.
<transport clientCredentialType="Windows" proxyCredentialType="None"
or with this in app.config
<transport clientCredentialType="None" proxyCredentialType="None"
<message clientCredentialType="UserName" algorithmSuite="Default" />
I get the error
BasicHttp binding requires that BasicHttpBinding.Security.Message.ClientCredentialType be equivalent to the BasicHttpMessageCredentialType.Certificate credential type for secure messages. Select Transport or TransportWithMessageCredential security for UserName credentials.
Basically what I want is to say in code "connect via windows auth" or "connect via anon auth" - I don't want to be changing app.config since the service could be either of these depending on the server its on - we have locally installed customers with windows auth and we have hosted customers with anon auth - so how can I get past this and have the code decide whether to connect with windows auto or anon auth ?