HTTP Authentication for web services
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.webservices.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Markus Brandy
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,
Markus Brandy
Reply to this message...
 
    
feroze [msft] (VIP)
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
=============

"Markus Brandy" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.AsyncCallback
System.ComponentModel.DesignerCategoryAttribute
System.Diagnostics.DebuggerStepThroughAttribute
System.IAsyncResult
System.Net.WebRequest
System.Web.Services.Protocols.SoapHttpClientProtocol
System.Web.Services.Protocols.SoapRpcMethodAttribute
System.Web.Services.WebServiceBindingAttribute




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com