waffel’s Weblog

Juli 27, 2017

calling NTLMv2 protected ASPX webservice with Spring Boot

Filed under: java,spring — Thomas Wabner @ 9:06 am

What a challenge. I tried to call a REST webservice from a ASPX website with my springboot application. The REST service only supports POST requests (I do not understand why, but this is maybe another story).

When I use the default spring RestTemplate to invoke a REST request I always get error 404 or 401 from the REST service. Doing the same with Chrome or IE the request works without any problem. So what is the difference?

It seems our browsers doing more than the spring RestTemplate. They are doing some roundtrips to handle NTLM authentication. The question is now: How can I do the same with spring?

The answer is fairly simple but I do not have found any official documentation about this. Simple do something like the following:


RestTemplate template = new RestTemplate();
// !!! We require this request to work with NTLMv2
template.headForHeaders("https://mydomain/theAspxService/");

The headForHeaders() method do the NTLMv2 authentication stuff. Any further requests using then the Ntlm auth header to talk with the ASPX service and they can then authenticate and invoke the requests.

For sure, you need general able to authenticate to the service. So check first with your browser if the requests really working for your windows user.

Advertisements

Schreibe einen Kommentar »

Es gibt noch keine Kommentare.

RSS feed for comments on this post. TrackBack URI

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

Erstelle eine kostenlose Website oder Blog – auf WordPress.com.

%d Bloggern gefällt das: