IMHO the problem with .NET is, that the PreAuthenicate Method doesn't work as
expected. The first call
is done without Authorization - Header, only subsequent calls get the right header.
But you can workaround this easily with a little subclassing:
| using System;
|
| public class MyWebService : your.original.WebService {
| protected override System.Net.WebRequest GetWebRequest(Uri uri) {
| System.Net.HttpWebRequest request =
(System.Net.HttpWebRequest)base.GetWebRequest(uri);
| if (this.PreAuthenticate) {
| System.Net.NetworkCredential nc =
this.Credentials.GetCredential(uri,"Basic");
| if (nc != null) {
| byte[] credBuf = new
System.Text.UTF8Encoding().GetBytes(nc.UserName + ":" + nc.Password);
| request.Headers["Authorization"] = "Basic " +
Convert.ToBase64String(credBuf);
| }
| }
| return request;
| }
| }
|
| class TestClient {
| public static void Main(string[] args) {
| MyWebService stub = new MyWebService();
| stub.Credentials = new System.Net.NetworkCredential("admin","secret");
| stub.PreAuthenticate = true;
| Console.WriteLine("Call hello: " + stub.hello("MyName"));
| }
| }
|
|
I hope this little C# example helps you and others too.
BTW: This was explained nicely on http://www.nsdev.org/jboss/stories/jboss-net.html,
but this
site seems down. Sad :-(
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3841996#3841996
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3841996
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user