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.
| 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
|
|
| |
| |
| 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]
|
|
| |
|
|
|
|
|