473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

HTTP Authentication for 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("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="MyServiceSoapBinding",
Namespace="http://localhost:8080/services/MyService")]
public class MyService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

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

[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
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
Nov 21 '05 #1
1 3841
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" <da******@gmx.net> wrote in message
news:b7**************************@posting.google.c om...
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("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="MyServiceSoapBinding", Namespace="http://localhost:8080/services/MyService")]
public class MyService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

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

[System.Web.Services.Protocols.SoapRpcMethodAttribu te("",
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Newbie | last post by:
I have set up an ASP script (with some help from microsoft.public.inetserver.asp.general!) that grabs the windows username of the user and puts it into an Access database. It is setup on IIS5 as a...
3
by: Niranjan Roy | last post by:
When trying to create Web application project from inside my Visual Studio.Net, I am getting the following error: --------------------------- Microsoft Development Environment ...
1
by: Invalidlastname | last post by:
Hi, Here is the issue: we have an ASP.NET application which is protected by Form authentication. The web application is hosted in the web-farm environment on multiple web servers. There are...
4
by: Trevor Andrew | last post by:
Hi There, Hopefully this isn't too difficult a question to express here. I have a 3 tier application. 1. Presentation Tier: ASP.NET web application. 2. Middle Tier: ASP.NET Web Services that...
5
by: Jon Skeet [C# MVP] | last post by:
I've run against a problem which I'm *sure* must be easy to solve - but I'm blowed if I can find the answer :( I have a web service which I want to require authentication. I need to authenticate...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
1
by: Tony Stephens | last post by:
Hi, I've created a small forms based application in c# to test a vendor's product and the web service interface that it exposes. We have deployed two instances of the vendor product one which...
10
by: Anton | last post by:
Hi, when accessing a secured 3rd party webservice i'm getting a 401 HTTP Statuscode (unauthorized). When entering the url in a browser and entering the username and password manually, the wsdl is...
0
by: Aelnk1954 | last post by:
I have a SharePoint Services 3.0 site running on a Windows 2003 server. The site uses windows authentication. On this server I also have a site that uses anonymous authentication (ASP.NET 2.0). On...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.