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

O

Ottavio

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
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Ottavio said:
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?

Something like:

CredentialCache auth = new CredentialCache();
NetworkCredential basic = new NetworkCredential("yourusername",
"yourpassword");
auth.Add(new Uri(yourwebservice.Url), "Basic", basic);
yourwebservice.Credentials = auth;

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top