.net - Send username and password in clear text to web service over HTTP -


i have vb.net (2008) console application consumes web service. started writing using old/legacy (pre-wcf) technology of importing wsdl wsdl.exe (or "add web service" in visual studio), creates classes based on system.web.services.protocols.soaphttpclientprotocol. however, realized not best way (thanks john saunders' comments in previous question -- how serialized xml of object passed web service?).

so, i've got code converted on wcf (using "add service reference", creates classes based on system.servicemodel.clientbase); , works more or less same, except 1 key point: security.

the web service consuming written in java; , while both (me, , team developed web service) work same company, don't have control on how publish , expose web service. requirement pass username & password (basic http authentication) on http, not https. know that's not secure way it; that's battle can't fight right now.

this worked fine using old way. if try wcf setting in app.config:

<security mode="transport">     <transport clientcredentialtype="basic" /> </security> 

... , setting username , password in code this:

oserviceclient.clientcredentials.username.username = "someusername" oserviceclient.clientcredentials.username.password = "somepassword" 

i have exception politely thrown @ me:

system.argumentexception: provided uri scheme 'http' invalid; expected 'https'. parameter name: via 

so sucks; , searching stackoverflow , other sites not turn in way of getting around in .net 3.5. found thing thought might promising (http://webservices20.blogspot.com/2008/11/introducing-wcf-clearusernamebinding.html); however, looks solution requires config changes on both service side , client side. , mentioned, don't have control on server side of this.

is there way accomplish using wcf-based client? or need give , go old way?

edit: seem having success this:

<security mode="transportcredentialonly">     <transport clientcredentialtype="basic" />     <message clientcredentialtype="username" /> </security> 

but security mode (transportcredentialonly) doesn't seem referenced in microsoft articles / tutorials. barking right tree?

the solution, in case, turned out setting security mode "transportcredentialonly", this:

<security mode="transportcredentialonly">     <transport clientcredentialtype="basic" proxycredentialtype="none"         realm="" />     <message clientcredentialtype="username" algorithmsuite="default" /> </security> 

credit evgenyl prompting me open research other security modes; in end, "transportcredentialonly" rather "message" did trick.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -