Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2004

Tip: Looking for answers? Try searching our database.

Re: Basic Authentication ... solution seems a mystery?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dominick Baier - 14 Sep 2004 07:11 GMT
sorry that i jump on at the end of the thread -

but isn't this the same as setting the credentials on the proxy`?

like proxy.Credentials = new NetCredentials("user", "pass") ?



---
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

  nntp://news.microsoft.com/microsoft.public.dotnet.framework.webservices/<ED16F739-3572-4F93-A431-188F6CCE23A8@microsoft.com>

Hi Jared ... bingo ... if one persists long enough. The solution is to
override in the GetResponse in the auto generated proxy class aka:

protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.WebRequest request = base.GetWebRequest (uri);

string username = "FFlinstone";
string password = "I_love_Wilma";

string auth = username + ":" + password;
byte[] binaryData = new Byte[auth.Length];
binaryData = Encoding.UTF8.GetBytes(auth);
auth = Convert.ToBase64String(binaryData);
auth = "Basic " + auth;

request.Headers["AUTHORIZATION"] = auth;

return request;
}

then one gets a header that looks like:

<HTTPHeaders>
<user-agent>Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 1.1.4322.2032)</user-agent>
<authorization>Basic RkZsaW5zdG9uZTpJX2xvdmVfV2lsbWE=</authorization>
<content-type>text/xml; charset=utf-8</content-type>
<soapaction>" "</soapaction>
<content-length>930</content-length>
<expect>100-continue</expect>
<connection>Keep-Alive</connection>
<host>localhost:8080</host>
</HTTPHeaders>

Which is exactly what I want :)

Many thanks for your time

"Jared" wrote:

> Pete,
> I have exhausted my knowledge of webservices, my experience with them is
> solely from the Microsoft platforms, where I can use my trusty soap headers
> and ICredentials. It seems as though everyone else has shied away from this
> post, I would try to find a group on Apache or try to post in the
> microsoft.public.framework.aspnet.webservices groups. Best of luck and when
> you find your answer post it so others can benefit.
> Jared
>
> "Pete" <phayward_delete@delete_bigfoot.com> wrote in message
> news:63863FD0-0911-4E0C-AD19-50DC9EAD35CD@microsoft.com...
> > Thanks Jared. You have excellently and precisely laid out the
> > functionality
> > of what I'm looking for except that I need it in the context of a "Web
> > Reference" that I have rather than a newly declared web client (which I
> > think
> > means I miss out on the ease of use of a web reference I presume). i.e I
> > need
> > to be able to "wind" backwards to the http context from the web reference
> > which seems to be protocol agnostic (which makes sense as protocols other
> > than http could potentially be used for the soap message). So I suppose a
> > better way to phrase the question is "How may I obtain the http context
> > from
> > a web reference?"
> > I could, I suppose construct the web service call "by hand" ignoring the
> > ease of use of Visual Studio inserting a web reference for me. But this
> > seems
> > such a pity as it would mean considerably more work (I think).
> >
> > Still, I'll look further into what you have suggested ...:)
> >
> > Thanks again.
> >
> > Pete
> >
> > "Jared" wrote:
> >
> >> Pete,
> >> I'm not talking about a browser or a web page, I too am talking about
> >> a
> >> ..NET WinForms application. Take the following code snippit for example:
> >>
> >> Sub PostAMessage()
> >> Dim Site As String = "http://www.yoursite.com"
> >> Dim Web As New System.Net.WebClient
> >> Web.Headers.Add("AUTHORIZATION", "SOMEVALUE")
> >> Dim Stream As System.IO.Stream
> >> Stream = Web.OpenRead(Site)
> >> Dim Reader As New System.IO.StreamReader(Stream)
> >> Dim Output As String = Reader.ReadToEnd()
> >> Stream.Flush()
> >> Stream.Close()
> >> Reader.Close()
> >> End Sub
> >>
> >> This code is declared and used inside a windows application. The name of
> >> the
> >> object I have been referring to is WebClient. You may want to see if it
> >> can
> >> handle what you are trying to do.
> >>
> >> Jared
> >>
> >> "Pete" <phayward_delete@delete_bigfoot.com> wrote in message
> >> news:5367C79D-9F26-44E1-A2AC-FCEFE8340BCD@microsoft.com...
> >> > Thanks Jared, however I'm not using a web client, I'm using Windows
> >> > Forms
> >> > client(and I've tried a console client to keep things simple with the
> >> > same
> >> > results). I have only have the web reference. So I think I need to be
> >> > able
> >> > somehow to get the web request object and from there access the Http
> >> > Request
> >> > object and from there be able to set the contents of the http header
> >> > ???
> >> > Anyone any clues or examples on how to do this? It's the same problem
> >> > as
> >> > my
> >> > orginal question however I'm not getting any closer it seems.
> >> >
> >> > When I use a Java client, it's really easy to set the http
> >> > AUTHORIZATION
> >> > attributes. Not so apparently in .Net. This is so basic I'll bet the
> >> > answer
> >> > is really easy but it has me stumped :)
> >> >
> >> > Pete
> >> >
> >> > "Jared" wrote:
> >> >
> >> >> I was referring to the System.Net.WebClient. You can send a post
> >> >> message
> >> >> to
> >> >> a client with this class, I believe you can modify the headers, it's
> >> >> been
> >> >> a
> >> >> while since i've used it.
> >> >>
> >> >> "Pete" <phayward_delete@delete_bigfoot.com> wrote in message
> >> >> news:C81F472B-0D1B-427D-A11C-5F449CCA06B6@microsoft.com...
> >> >> > Thanks ... however I am aware of this, but the Credentials technique
> >> >> > (discussed int the link you kindly prvided) passes the credentails
> >> >> > at
> >> >> > the
> >> >> > SOAP Header level not the HTTP header level which in my case is
> >> >> > desired
> >> >> > for
> >> >> > the APache/AXIS server.
> >> >> > In the meantime I am looking at the info that Jared supplied.
> >> >> > PS I'm not using a web client, rather a windows forms client.
> >> >> > Pete
> >> >> >
> >> >> > "old" wrote:
> >> >> >
> >> >> >> take a look at this link
> >> >> >> Pass Current Credentials to an ASP.NET Web Service
> >> >> >> http://support.microsoft.com/?kbid=813834
> >> >> >>
> >> >> >> "Jared" <VB_Puzzled_VB@email.com> wrote in
> >> >> >> news:10k4qkv20mnpof6@corp.supernews.com:
> >> >> >>
> >> >> >> > Sorry about that.
> >> >> >> > Try looking into the System.Net.WebHeaderCollection object or
> >> >> >> > the
> >> >> >> > System.Net namespace in general. The webclient may have the
> >> >> >> > functionality you are looking for.
> >> >> >> >
> >> >> >> > "Pete" <phayward_delete@delete_bigfoot.com> wrote in message
> >> >> >> > news:ACB1E631-E8D4-4B43-AE85-50E9B8484994@microsoft.com...
> >> >> >> >> Thanks Jared,
> >> >> >> >> However I'm looking for authentication at the http level not at
> >> >> >> >> the
> >> >> >> >> soap level.
> >> >> >> >> The SOAP/AXIS server I'm looking to connect my client desires
> >> >> >> >> basic
> >> >> >> >> authentication
> >> >> >> >> within the http header.
> >> >> >> >> ie looking to see how to set the AUTHENTICATION attribute within
> >> >> >> >> the
> >> >> >> >> http header.
> >> >> >> >> Pete
> >> >> >> >>
> >> >> >> >> "Jared" wrote:
> >> >> >> >>
> >> >> >> >>> I think you just have to create a class that inherits from
> >> >> >> >>> SoapHeader, then
> >> >> >> >>> include the <SoapHeader()> attribute to the method that will
> >> >> >> >>> use
> >> >> >> >>> it.
> >> >> >> >>> I hope
> >> >> >> >>> I understood your question correctly.
> >> >> >> >>>
> >> >> >> >>> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystem
> >> >> >> >>> WebServicesProtocolsSoapHeaderAttributeClassTopic.htm
> >> >> >> >>>
> >> >> >> >>> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconalte
> >> >> >> >>> ringsoapmessageusingsoapextensions.htm
> >> >> >> >>>
> >> >> >> >>> "Pete" <phayward_delete@delete_bigfoot.com> wrote in message
> >> >> >> >>> news:740572F4-22A7-489E-9ADA-2148034D13D1@microsoft.com...
> >> >> >> >>> > I'm cross posting from mscom.webservices.general as I have
> >> >> >> >>> > received no answer
> >> >> >> >>> > there:
> >> >> >> >>> >
> >> >> >> >>> > There has been a number of recent posts requesting how to
> >> >> >> >>> > satisfactorily
> >> >> >> >>> > enable BASIC authorization at the HTTP level but as yet no
> >> >> >> >>> > fully
> >> >> >> >>> > useful answer.
> >> >> >> >>> >
> >> >> >> >>> > I too have been trying to call an apache/axis webservice
> >> >> >> >>> > which
> >> >> >> >>> > desires a
> >> >> >> >>> > username/password from my C# Client. (ie the equivalent of
> >> >> >> >>> > _call.setUsername("Myname") name from within a Java client
> >> >> >> >>> > proxy)
> >> >> >> >>> > Try as I
> >> >> >> >>> > may I cannot get the AUTHORIZATION attribute to be included
> >> >> >> >>> > in
> >> >> >> >>> > the
> >> >> >> >>> > http header. Some mention has been made of directly inserting
> >> >> >> >>> > the
> >> >> >> >>> > attribute into
> >> >> >> >>> > the header ... but how does one get hold of the request
> >> >> >> >>> > object
> >> >> >> >>> > to
> >> >> >> >>> > do this?
> >> >> >> >>> > Using the Credentials object method does not work for me.
> >> >> >> >>> >
> >> >> >> >>> > Any clues ..?


[microsoft.public.dotnet.framework.webservices]
Jared - 14 Sep 2004 11:46 GMT
I hope not, Pete said that will not work in this solution.

<pete>
however I am aware of this, but the Credentials technique
(discussed int the link you kindly prvided) passes the credentails at the
SOAP Header level not the HTTP header level which in my case is desired for
the APache/AXIS server
</pete>

> sorry that i jump on at the end of the thread -
>
[quoted text clipped - 267 lines]
>
> [microsoft.public.dotnet.framework.webservices]

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.