Erik Mandke
Erik Mandke

Reputation: 1667

ASP.net Webservice *.asmx access with WCF Service Reference

Assume I have a ASP.net Webservice. The older version with *.asmx-Files . Running on IIS 8

When I try to access it via "Add Service Reference" in Visual Studio with a WCF-Service Client it does not work.

My Problem is "Basic HTTP Authentication"..

Error Message

{"Die HTTP-Anforderung ist beim Clientauthentifizierungsschema \"Anonymous\" nicht autorisiert. Vom Server wurde der Authentifizierungsheader \"Basic Realm=\"WebsitePanel Enterprise Server\"\" empfangen."}

Translated

{"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=\"WebsitePanel Enterprise Server\"'"}

When I use "Web Reference" it does work . [ I am using WebsitePanel and try to access its Enterprise-Server Webservices (asmx-files) ]

Is it possible to use old ASMX-Webservices with "WCF Service Reference"-Clients ? Can somebody explain the differences, what I should use ?

Upvotes: 2

Views: 1278

Answers (1)

Jan Köhler
Jan Köhler

Reputation: 6030

Based on the comments on your question I'd assume you forgot to provide some authentication informations. By providing a valid username and password along your proxy-object you should be able to invoke the service:

client.ClientCredentials.UserName.UserName = "foo";
client.ClientCredentials.UserName.Password = "bar";
client.SomeMethod();

Additionally you should ensure to set your config to Transport (or TransportCredentialOnly and clientCredentialType="Basic"):

<bindings>
  <basicHttpBinding>
    <binding name="myBinding">
      <security mode="Transport">
        <transport clientCredentialType="Basic" proxyCredentialType="None" realm="WebsitePanel Enterprise Server" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

To get more detailed error information, configure tracing: http://msdn.microsoft.com/en-us/library/ms733025%28v=vs.110%29.aspx

Upvotes: 1

Related Questions