jan-vavra
jan-vavra

Reputation: 11

Preauthenticate in .net 4.5 web service client

I've tried to write a .net client that call java web service with http basic authentication. The service consumes files. So I'd like to persuade the .net web service client framework to send Authorization header at first time.

In previous versions of .net there was a property PreAuthenticate. How could I apply this on WCF web service client?

In my hands I have only instance of testOperationsPortTypeClient that is descendant of System.ServiceModel.ClientBase<.>. No such property or callback is present for it.

Upvotes: 1

Views: 2665

Answers (1)

Theo Gray
Theo Gray

Reputation: 89

One option is to remove the current Service Reference you have and then do the following:

  1. Go back to the Add Service Reference dialog
  2. Click 'Advanced' button (bottom-left)
  3. Click 'Add Web Reference...' button at the bottom of the Advanced screen under 'Compatibility'

This will take you to the old Add a Web Service reference screen from .Net 2.0. Adding the reference to the web service using this will create the wrappers inheriting from SoapHttpClientProtocol which includes PreAuthenticate, etc

Upvotes: 1

Related Questions