0

I want to call a web service from my winforms application. My application is written on c# and the webservice is secured using spring security.

Is it possible to login to the website and call that web service?.

If it is possible how to do that?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Sumodh S
  • 709
  • 1
  • 14
  • 36
  • Sure, do you have an existing Spring security configuration? – holmis83 Jun 16 '15 at 09:59
  • Yes, I have, and the web service is deployed in google app engine. The service I need call is a secured URL. So I need to login first. I tried using the solution explained here. – Sumodh S Jun 17 '15 at 06:06
  • http://stackoverflow.com/questions/975426/how-to-programmatically-log-in-to-a-website-to-screenscape – Sumodh S Jun 17 '15 at 06:06
  • But I were unable to login. I have changed the field names and URL as per the spring specification. But still it was not logging in – Sumodh S Jun 17 '15 at 06:07

1 Answers1

1

Authentication can be setup in many ways with Spring Security. For example:

<http pattern="/webservice/**" create-session="stateless" realm="TestRealm">
  <http-basic/>
  <intercept-url pattern="/**" access="ROLE_USER"/>
</http>

Then it is as simple as this to authenticate from C#:

var request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential(username, pwd);
holmis83
  • 15,922
  • 5
  • 82
  • 83