473,385 Members | 1,353 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.

how to add "Authorization: Basic" for a web service call

Hello,
I'm having some problems with the authentication during a web service
call
I know I have to add the "Authorization: Basic xxxxxxxx" in the http
header (not soap header) but I can't find a way to add it.
I've tryed to use ethereal to watch what I'm sending and I can see all
the header
(Accept-Language,Accept-Encoding,User-Agent,Host,Connection,..) and the
SOAP xml message but there is no "Authorization: Basic ......" at all.
Could someone help me?
This is the [partial] code I'm using:

namespace WCM
{
public partial class Form1 : Form
{
public Form1(){InitializeComponent();}
private void button1_Click(object sender, EventArgs e)
{
//WSDL web reference: WebRef
//WebService: Service
WebRef.ServiceTTService = new WCM.WebRef.Service();
NetworkCredential remoteCredentials = new NetworkCredential("a",
"b");
TTService.Credentials = remoteCredentials;
WebRef.TTRequestType TTRequest = new WCM.WebRef.TTRequestType();
TTRequest.param="param";
WebRef.TTRespType TTResponse = new WCM.WebRef.TTRespType();
TTResponse = TTService.TTRequestMethod(TTRequest);
//ERROR ON THE PREVIOUS LINE:
//"The request failed with HTTP status 403: Service Error."
MessageBox.Show("DONE!");
}
}
}

Thank you in advance!
Ottavio

Nov 8 '06 #1
2 7535
Hi Ottavio,

First of all, the virtual directory where the service is hosted must not
accept anonymous access (If it does, the client application never sends the
username and password, it always prefer to be anonymous).
Finally, you have to use the following code to add the username and password
(Basic Authentication):

// Create Web Service object.
MyService myserv = new MyService() ;

// Create credentials object.
NetworkCredential objCredential =
new NetworkCredential("user", "password", "yourdomain") ;

// Let Web Service know about your credentials.
myserv.Credentials = objCredential ;

// Call method on Web Service.
myserv.HelloWorld();

Regards,
Pablo.

"Ottavio" <Ot*******************@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hello,
I'm having some problems with the authentication during a web service
call
I know I have to add the "Authorization: Basic xxxxxxxx" in the http
header (not soap header) but I can't find a way to add it.
I've tryed to use ethereal to watch what I'm sending and I can see all
the header
(Accept-Language,Accept-Encoding,User-Agent,Host,Connection,..) and the
SOAP xml message but there is no "Authorization: Basic ......" at all.
Could someone help me?
This is the [partial] code I'm using:

namespace WCM
{
public partial class Form1 : Form
{
public Form1(){InitializeComponent();}
private void button1_Click(object sender, EventArgs e)
{
//WSDL web reference: WebRef
//WebService: Service
WebRef.ServiceTTService = new WCM.WebRef.Service();
NetworkCredential remoteCredentials = new NetworkCredential("a",
"b");
TTService.Credentials = remoteCredentials;
WebRef.TTRequestType TTRequest = new WCM.WebRef.TTRequestType();
TTRequest.param="param";
WebRef.TTRespType TTResponse = new WCM.WebRef.TTRespType();
TTResponse = TTService.TTRequestMethod(TTRequest);
//ERROR ON THE PREVIOUS LINE:
//"The request failed with HTTP status 403: Service Error."
MessageBox.Show("DONE!");
}
}
}

Thank you in advance!
Ottavio

Nov 8 '06 #2
The code I'm using is the same but I'm getting the error on the
"myserv.HelloWorld()"-like line.
Maybe I'm using it in the wrong way:
1- I was provided of username and password (no domain) as network
credential
2- the WSDL I have to use has been sent to me by e-mail, I have no
http:/...?WSDL address
3- I saved the WSDL in a folder in my server C:\...\WSDL\name.wsdl
4- I added the web-reference pointing to the local file
C:\...\WSDL\name.wsdl
You were talking about "virtual directory where the service is
hosted"...have I missed something?
Thank you,
Ottavio

Pablo Cibraro [MVP] ha scritto:
Hi Ottavio,

First of all, the virtual directory where the service is hosted must not
accept anonymous access (If it does, the client application never sends the
username and password, it always prefer to be anonymous).
Finally, you have to use the following code to add the username and password
(Basic Authentication):

// Create Web Service object.
MyService myserv = new MyService() ;

// Create credentials object.
NetworkCredential objCredential =
new NetworkCredential("user", "password", "yourdomain") ;

// Let Web Service know about your credentials.
myserv.Credentials = objCredential ;

// Call method on Web Service.
myserv.HelloWorld();

Regards,
Pablo.

"Ottavio" <Ot*******************@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hello,
I'm having some problems with the authentication during a web service
call
I know I have to add the "Authorization: Basic xxxxxxxx" in the http
header (not soap header) but I can't find a way to add it.
I've tryed to use ethereal to watch what I'm sending and I can see all
the header
(Accept-Language,Accept-Encoding,User-Agent,Host,Connection,..) and the
SOAP xml message but there is no "Authorization: Basic ......" at all.
Could someone help me?
This is the [partial] code I'm using:

namespace WCM
{
public partial class Form1 : Form
{
public Form1(){InitializeComponent();}
private void button1_Click(object sender, EventArgs e)
{
//WSDL web reference: WebRef
//WebService: Service
WebRef.ServiceTTService = new WCM.WebRef.Service();
NetworkCredential remoteCredentials = new NetworkCredential("a",
"b");
TTService.Credentials = remoteCredentials;
WebRef.TTRequestType TTRequest = new WCM.WebRef.TTRequestType();
TTRequest.param="param";
WebRef.TTRespType TTResponse = new WCM.WebRef.TTRespType();
TTResponse = TTService.TTRequestMethod(TTRequest);
//ERROR ON THE PREVIOUS LINE:
//"The request failed with HTTP status 403: Service Error."
MessageBox.Show("DONE!");
}
}
}

Thank you in advance!
Ottavio
Nov 8 '06 #3

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

Similar topics

1
by: bidalah | last post by:
Hello, I am looking for basic info on installing and using MSDE. I am trying to install and play with MSDE on my PC (Win2000). I finally managed to work my way through installation, and named...
1
by: deko | last post by:
This sub pulls Outlook Appointments into a table. The problem is I want to limit the import to Location = Boston I'm not sure how to code that into the For... To loop - As it is now, I get the...
18
by: steve | last post by:
I'm trying to create a structure of three pointers to doubles. For which I have: typedef struct { double *lst_t, *lst_vc, *lst_ic; } last_values; I then need to allocate space for...
3
by: Keith Rebello | last post by:
I have an object called ColumnSection which represents a reinforced concrete column. This object contains an arraylist called Diagrams which contains Graph2D objects which are essentially X-Y...
1
by: Ottavio | last post by:
Hello, I'm having some problems with the authentication during a web service call I know I have to add the "Authorization: Basic xxxxxxxx" in the http header (not soap header) but I can't find a...
43
by: Bill H | last post by:
25 years ago every computer came with some form of Basic interpreter so you could use yoru computer without having to buy more software. Is Javascript (teamed with HTML) set to become the new...
5
by: dabei | last post by:
Hi, I am trying to use AS3 to make a URL request with authorization header. Using the code below: var request:URLRequest = new URLRequest ( 'http://myserviceURL' ); var...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.