all groups > dotnet web services > june 2004 >
You're in the

dotnet web services

group:

HTTP Authentication for web services


HTTP Authentication for web services da_joker NO[at]SPAM gmx.net
6/28/2004 6:10:20 AM
dotnet web services: Hi,

I have to use a Java web service that requires HTTP authentication, so
I have to send username and password in the HTTP headers.

My C# application has a client implementation that looks like this:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="MyServiceSoapBinding",
Namespace="http://localhost:8080/services/MyService")]
public class MyService :
System.Web.Services.Protocols.SoapHttpClientProtocol {

public MyService() {
this.Url = "http://localhost:8080/services/MyService";
}

[System.Web.Services.Protocols.SoapRpcMethodAttribute("",
RequestNamespace="http://webservices.my",
ResponseNamespace="http://localhost:8080/services/MyService")]
public void addUserData(UserData in0) {
this.Invoke("addUserData", new object[] {
in0});
}

public System.IAsyncResult BeginaddUserData(UserData in0,
System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("addUserData", new object[] {
in0}, callback, asyncState);
}

public void EndaddUserData(System.IAsyncResult asyncResult) {
this.EndInvoke(asyncResult);
}
};

The client uses the service like this:

MyService myService = new MyService();
myService.addUserData(userData);

It works fine, if no authentication is required. How can I implement
the HTTP authentication?

Thanks,
Re: HTTP Authentication for web services feroze [msft]
6/30/2004 11:46:27 PM
There are two ways that I can think of:

1) if the proxy supports setting credentials, set the credentials using
that.
2) You can override the GetWebRequest() method of gthe proxy. Then, on the
WebRequest object that you get, you can set NetworkCredentials.

feroze
=============

[quoted text, click to view]

AddThis Social Bookmark Button