This site uses cookies. By continuing you accept the use of cookies.I Accept

For the moment I’m working on a project with the Swedish Police, building an Adapter for an existing data application. The adapter that I’m developing communicates with a SOAP Web Service hosted on Apache. The data that is received is then transported back to the existing application. Quite the simple task, if it wasn’t for a very strange behavior in Microsoft .Net.

The SOAP Web Service requires authentication and if authentication fails it responds with a 401 error.

So I wrote this code and thought it should work.

image

As soon as we called a method in the Web Service, it responded with the 401 error. So I set the property PreAuthenticate to true.

image

That didn’t work either, so my first thought was that something must be wrong with the Web Service, or that I had been given the wrong credentials.

After a few hours of searching various forums I finally found the solution. Apparently the authentication is not added to the Http Header (as it should have been). So the solution was to subclass the Web Service class and implement some additions.

image

With this code in place, it’s now possible to add the authentication header to the Web Service.

image

image

Finally the call is authenticated and I received data from the Web Service.