473,698 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to modify the HTTP Header for a WebService in .NET 2.0

Hi,

I'm trying to include some user credentials for accessing a remote
webservice. The remote location requires that I use Basic
authentication, which means, from browsing around, I need to include
the user name and password in the HTTP header, but I'm not quite sure
how to access the HTTP header that is sent with the webservice soap
message request.

Can anyone help?

Thanks in Advance.

Kevin

Feb 15 '06 #1
6 4401
You should be able to pass a NetworkCredenti al object to the webservice
proxy that uses the specified user name, password, and domain and pass this
with the request to the remote webservice. This would be added to the
outbound header when the request is made.

Have a read of this for an example.

http://support.microsoft.com/kb/811318/EN-US/

--
Regards

John Timney
Microsoft MVP

<ut*********@gm ail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hi,

I'm trying to include some user credentials for accessing a remote
webservice. The remote location requires that I use Basic
authentication, which means, from browsing around, I need to include
the user name and password in the HTTP header, but I'm not quite sure
how to access the HTTP header that is sent with the webservice soap
message request.

Can anyone help?

Thanks in Advance.

Kevin

Feb 15 '06 #2
I tried your suggestion, which I have used in the past to pass
credentials. In this instance, I'm needing to send the credentials via
the HTTP headers, not part of the soap headers. According to RFC 2617,
the HTTP header should include "Authorizat ion: Basic uid:password"
format. Using the trace built into IIS I looked at the incomming
request to the webservice to locate the header information and check if
any credentials that I set was found within the header, but could not
find any.

this is the information in the HTTP header:

Headers Collection
Name Value
Connection Keep-Alive
Content-Length 4068
Content-Type text/xml; charset=utf-8
Expect 100-continue
Host localhost
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 2.0.50727.42)
VsDebuggerCausa lityData
uIDPowZg+yq+Zv9 BnmiKUtX0pxsBAA AANneykaH6Wky4N 0BqGyE1RI8QHDH3 KGRPmY2NJ9d7/egACAAA

SOAPAction "http://tempuri.org/GetVersion"

-----------------------------------------------------------------

Here's a snippet of what code i used to set the network credentials.

System.Net.Netw orkCredential cred = new
System.Net.Netw orkCredential(" user", "user");
System.Net.Cred entialCache cache = new
System.Net.Cred entialCache();
cache.Add(new Uri("www.webser vice.asmx"), "Basic",
cred);
webService.Cred entials = cache;

Am I going about this the wrong way?

Thanks.

Feb 15 '06 #3
Specifically for SOAP headers .NET lets you derive from the soap header
class to pass authentication if the network credentials cant cut it. I've
never tried it but it might be just what your after.

Theres a simple example of it here in the quickstart:
http://samples.gotdotnet.com/quickst...eservices.aspx

and another worth reading at Code Project
http://www.codeproject.com/cs/webser...ebservices.asp

Hope that helps
--
Regards

John Timney
Microsoft MVP

"UT-BadBoy" <ut*********@gm ail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
I tried your suggestion, which I have used in the past to pass
credentials. In this instance, I'm needing to send the credentials via
the HTTP headers, not part of the soap headers. According to RFC 2617,
the HTTP header should include "Authorizat ion: Basic uid:password"
format. Using the trace built into IIS I looked at the incomming
request to the webservice to locate the header information and check if
any credentials that I set was found within the header, but could not
find any.

this is the information in the HTTP header:

Headers Collection
Name Value
Connection Keep-Alive
Content-Length 4068
Content-Type text/xml; charset=utf-8
Expect 100-continue
Host localhost
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 2.0.50727.42)
VsDebuggerCausa lityData
uIDPowZg+yq+Zv9 BnmiKUtX0pxsBAA AANneykaH6Wky4N 0BqGyE1RI8QHDH3 KGRPmY2NJ9d7/egACAAA

SOAPAction "http://tempuri.org/GetVersion"

-----------------------------------------------------------------

Here's a snippet of what code i used to set the network credentials.

System.Net.Netw orkCredential cred = new
System.Net.Netw orkCredential(" user", "user");
System.Net.Cred entialCache cache = new
System.Net.Cred entialCache();
cache.Add(new Uri("www.webser vice.asmx"), "Basic",
cred);
webService.Cred entials = cache;

Am I going about this the wrong way?

Thanks.

Feb 16 '06 #4
Hi John,

Thanks for the two links. They definately provided me with more
information about the soap headers and how you can use the soap headers
to place additional information for webservice requests. But
unfortunately, the third party webservices that we are using require
that we place the authentication strings within the
HTTP Headers. Is there a way to implement this within the webservice
or is this something I need to configure IIS to do when sending out
requests?

Thanks again.

Feb 21 '06 #5
Hi John,

Thanks for the two links. They definately provided me with alot of
information about the webservice soap headers but it seems in my
situation that I need access to the HTTP Headers.
The third pary webservices that we will use requires that we place the
authentication credentials within the HTTP header's Authentication
section.
Is this some sort of configuration that I can set within the IIS?

Thanks.

Feb 21 '06 #6
The authentication property preauthenticate =true on your wsdl proxy should
force the authentication headers into the http stack as opposed to the soap
stack. I suspect this is what your actually after as it handles 401 status
codes and deals with an http challenge during the actual request, thus
authenticating the call at the http header level.

http://msdn2.microsoft.com/en-us/lib...henticate.aspx

Another MVP - Peter Bromberg has an excellent article on pre-authenticating
web service requets and security. You should read it.
http://www.eggheadcafe.com/articles/20051104.asp

If this isn't what your looking for then you need to get a working example
from the web service owner and base your solution on that.

Hope I have helped!.

Regards

John Timney
Microsoft MVP

"UT-BadBoy" <ut*********@gm ail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi John,

Thanks for the two links. They definately provided me with more
information about the soap headers and how you can use the soap headers
to place additional information for webservice requests. But
unfortunately, the third party webservices that we are using require
that we place the authentication strings within the
HTTP Headers. Is there a way to implement this within the webservice
or is this something I need to configure IIS to do when sending out
requests?

Thanks again.

Feb 21 '06 #7

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

Similar topics

15
3008
by: Shaun Wilde | last post by:
I am not sure if this is a .NET bug/feature and IIS5 one or a combination of the 2 so here goes I have a situation where when I call an ASP.NET webservice running under windows 2000 (I assume IIS5) with a webservice client also in .NET that the webservice request loses the Authorization HTML header. This DOES NOT happen under Windows 2003. I am using the followng (patch/fix) to preauthenticate the web request (this
0
1263
by: mcquiggd | last post by:
Hi, I have a proxy object to a webservice which exposes a Header collection.. I have also created a class that inherits from SoapHeader and has a single property; this class is then added to the Header collection on the property and is included in the serialised Xml which is sent to the webservice... However! Schema validation on the server fails as the Xml tree
6
6091
by: Dave Slinn | last post by:
I have a VB app hosting the Webbrowser control. I would like to add "something" to the requests that app is submitted to our web application to indicate that its from this webbrowser and not a separate instance of IE. Is this possible, keeping in mind that I cannot add anything to the registry, since a user may still use IE to visit the web app.
0
937
by: Friso Wiskerke | last post by:
Hi all, I'm trying to use a webservice which is provided to me by a third party. There are a number of webmethods that I can call but for each method I have to supply a SOAP header which contains an identification-token. I've managed to generate a proxy class using the wsdl.exe tool but the wsdl doesn't have the SOAP header definition in it (quite frustrating). I'm trying to enhance the generated class so that I can issue the header to...
3
3215
by: Maxwell2006 | last post by:
Hi, When I run a web service project, ASP.NET shows me a default web method invoke page. How can I disable/modify the default test (or method invoke) page of the ASP.NET web services? Thank you, Max
5
1419
by: Debasish Pramanik | last post by:
Hi All, I have added a SoapHeader in my websevice, which is exposed as a variable from my webservice. Whenver I access the header form my client I see the name of variable being changed to <VaribaleName>Value. public class MyClass: System.Web.Services.WebService {
2
18127
by: =?Utf-8?B?TWlndWVsIElzaWRvcm8=?= | last post by:
Hi, I've built an ASP.NET 1.1 web service and an ASP.NET 1.1 application that calls it is throwing the following exception: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://ipm.sitefactory.com/Authenticate. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at
5
1996
by: nasse | last post by:
I am getting the following error msg whenever I try to login. I tried to turn my output_buffering = On in my php.ini but is not working for me. Would you please help me: Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub ........login\include\header.php:9) in C:\Inetpub\vhosts\.....\httpdocs\login\login.php on line 23 And here is the content of the header.php page which is included in all my...
10
9771
by: Anton | last post by:
Hi, when accessing a secured 3rd party webservice i'm getting a 401 HTTP Statuscode (unauthorized). When entering the url in a browser and entering the username and password manually, the wsdl is returned. So the username and password should be ok. I'm using this code: Merchant myMerch = new Merchant(); myMerch.merchantIdentifier=merchantId;
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.