Problem: Consuming an Apache Web Service

G

Guest

Hello all

I've a problem, I need to develop a component to connect a web
service for
sending SMS. The web service it's not implemented in .NET.I need to use basic
authentication (at least that is what I've been told). The most strange thing
is that when I add the web reference in Visual Studio .NET I'm not asked for
authentication. Apart from this, it's the web service who tells me I'm not
authenticated
instead of the server.
I've monitored the HTTP packets, sent and received, of a correct execution.
The
only significant difference is that the header of the first HTTP packet is
the following line:
"Authorization: Basic cGlhj2dsOmcfswnNzcGgg7e="

When it's me who runs the service I can't get that line to be sent.

On the other hand, I've created a test web service in other machine using
..NET
and using basic authentication. When developing a client, at the point that
the web reference
is added, i'm requested to type a user and passwd. When running the client,
I monitor the net and
that line ("...Authorization....") is present.

does anyone know why this line would not be included in the HTTP header when
using an apache server??
Thanks a lot.
 
W

Wessel Troost

"Authorization: Basic cGlhj2dsOmcfswnNzcGgg7e="You have to add the header yourself:

YourWebRequest.Headers.Add("Authorization", "Basic "
+ "cGlhj2dsOmcfswnNzcGgg7e=";

Greetings,
Wessel
 
G

Guest

very thanks.

that works with a web request, but would you know how to do this with a web
service client on visual studio .net. It doesn't have that method
(Header.Add) in my web service consumer class.
 
G

Guest

As I said, the service class doesn't have the GetWebRequest method, but the
SoapHttpClientProtocol class from which it inherits has this method as
protected. I'll try to make it public on my service class.

I'll keep you informed, ;)
 
G

Guest

Hi all again,

I've found the solution for my problem. I've overrided the GetWebRequest
method as follow:

protected override System.Net.WebRequest GetWebRequest(System.Uri uri) {
System.Net.WebRequest req = base.GetWebRequest(uri);
req.Headers.Add("Authorization", "Basic cGdSY2asOmFhdfanNGxwaWd9");
return req;
}

Thanks all again
 

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