简体   繁体   中英

Soap service credential available from InputStream

For a project I am doing, I am using a SOAP service to access some data from another system. I added the SOAP service as a web reference to my ASP.NET (C#) project.

Now, the service is kinda complicated, because a user has to be authenticated first with a cookie (don't ask). So what we did was:

  • The user accesses our website.
  • Website redirects the user to a logon page on the server where the service is located.
  • User logs on, and a FormsAuthentication.SetAuthCookie is performed
  • User is redirected back to our site. Which then forwards the user to a page which should contain data from the webservice.

That page instantiates the webservice as an object like this:

MyService.MyServiceservice = new MyService.MyService();

Then I put the credentials in (now I do it hardcoded):

service.PreAuthenticate = true;
service.Credentials = new NetworkCredential("Wim", "mypass");

When I call a method on that service, I want the Global.asax on the server containing the server, to be able to "catch" the username and password from the request. But somehow I cannot fetch it.

Don't ask why it has to be done like this, lets call it .. unfortunate :P

Does anyone know how to fetch the username and password from that request on the server side, preferable in the Global.asax Application_BeginRequest.

What authentication mode is the service using? Basic, Digest? etc.

If it is basic, then the username and password will be in the http header as a Base64 encoded string that will look something like GWxhCGRpbjpvcGVuIFNlc2FtZG==.

You'll need to decode it and then you'll see the username and password in this format user:password.

Where are you looking/expecting to find the username and password?

As a side note: If you're writing the service as well, then you should probably use an "Authentication" module rather than doing it in Global. hook into the OnAuthenticate event of global in an HttpModule and do the authentication there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM