Practical examples for establishing Web service security in .NET

Daily Newsletters

Sign up to ZDNet UK's daily newsletter.

ANALYSIS
Because security is one of the most fundamental aspects in the development and deployment of a Web service, there are a myriad of articles, documentation, and samples of how to make it secure. Yet the majority of this information is conveyed as abstract theory, as opposed to practical, real-world implementation. Here, I'll share some practical examples on Web service security in .NET, not just abstract theories. These examples provide an easy and fast way to accomplish a rather complex task. Let's explore programmatic Web service security using Visual Studio .NET to implement a custom, stateful SOAP Header to authenticate a consumer before allowing a method to execute. I will also show you how to remove public access to your Web service, how to prevent anonymous users from obtaining your WSDL file, and how to implement your Web service in an unauthorised manner. I will then explain how you can wrap your entire Web service implementation in a highly secure, encrypted format. A reusable security pattern
Web services are typically built as an add-in functionality or as an API on top of an existing ASP.NET application. The Web service may interact directly with your database or in an N-tier solution by calling intermediary components to perform the functionality. Your Web service needs to know who is invoking it and what privileges that user has in your application. More than likely, your users, roles, business rules, and authorisations have already been implemented, and you simply want to tap into this existing information. To do this, your Web service needs to implement a pattern for determining the requesting client's credentials. You could, in theory, pass a user ID and password to every method in your Web service, but a more object-oriented approach is to create a class that extends System.Web.Services.Protocols.SoapHeader. This class will become your SOAP Header, which is passed to your Web service and will include everything needed to authenticate your client. Server implementation
Listing A shows the server-side implementation code of a simple Web service, SecureWebServiceTester.asmx, and its associated SOAP Header class. The SecurityContext class extends the SoapHeader class, which tells the .NET Framework that it's a Soap Header and allows you to reference this class in the attribute. The main class, SecureWebServiceTester, contains the actual implementation methods for the Web service. These methods are denoted with the attribute. The LoginUser() function takes in an instance of your SecureContext Soap Header class and uses this object as it would any other object. Note that the object name is referenced within quotation marks and is matched to the secureCtx class attribute.

Talkback

Why do I click on the Listing A hyperlink to only be taken to a page that is not listing A and has nothing to do with this article?

via Facebook 20 April, 2004 17:10
Reply

Hi,

Good day to you.

I am impressed after reviewing your web site and company services.

Here I would like to propose a "mission-critical" solution to boost your sales, marketing and customer service via your web site. We have a solution known as BOTizen | www.botizen.com that could complement your business to achieve great result.

We have a very interesting proposition to propose that could add value to your company’s services.

Can you please direct me to the appropriate person in charge so that I can get in touch with him/her immediately? I would appreciate if you could send me his/her name and e-mail address for contact.

Thank you very much.

via Facebook 29 June, 2004 05:44
Reply

Great!
But I can't found source code

via Facebook 21 August, 2004 17:38
Reply

For everybody who cannot open the Listings use this Link to view the Article

http://builder.com.com/5100-6389-5034851.html#Listing%20A

via Facebook 10 February, 2005 15:16
Reply

This is a great article but it seems that the code samples links are broken (Listing A and B) which is not too good. Do you have those available somewhere or updated links that you could send me?

via Facebook 17 July, 2006 12:26
Reply

Post your comment

In order to post a comment you need to be registered and logged in.

You can also log in with Facebook. Log in or create your ZDNet UK account below

  • Login

Will not be displayed with your comment

By signing up for this service, you indicate that you agree to our Terms and Conditions and have read and understood our Privacy Policy. Questions about membership? Find the answers in the Community FAQ

Get ZDNet UK's daily newsletter

Enter your email address to sign up

ZDNet UK Live

bdantas

Excellent article. One small correction, though--although a fresh installation of Linux Mint 12 will, indeed, provide the user with a version of...

25 minutes ago by bdantas on A tale of two distros: Ubuntu and Linux Mint
Alan Ralph

In related news, the ISPs club together to get the members of the Home Affairs Select Committee (ya goofed on that part, ZDNet UK) copies of "The...

54 minutes ago by Alan Ralph via Facebook on MPs urge ISPs to take down terrorist material
Alan Ralph

In related news, the ISPs club together to get the members of the Home Affairs Select Committee (ya goofed on that part, ZDNet UK) copies of "The...

59 minutes ago by Alan Ralph via Facebook on MPs urge ISPs to take down terrorist material
Moley

For Gnome 2 die-hards, it is possible to add icons to the bottom panel (or top top panel, if you prefer) which provide the exact Gnome 2...

2 hours ago by Moley on A tale of two distros: Ubuntu and Linux Mint
ramwellian

Your comments would seem pretty naive and immature. Your 'solution' appears to be, "gee, let's all just give in to the hackers and give them...

2 hours ago by ramwellian on Cloud computing security: no more oxymoron?
BugStalker

"Interesting thought ... If you installed Win7 as a dual boot on a machine that previously only had Linux, and it wrecked your Linux installation,...

2 hours ago by BugStalker on Windows 7 Declares War on GRUB
whs001

This is an excellent summary of Ubuntu and Mint and the interface differences between them. Most such articles take a very partisan position for...

2 hours ago by whs001 on A tale of two distros: Ubuntu and Linux Mint
Moley

@ewallace. Not so clear. Anyone can obtain the text, for example from here http://www.ustr.gov/webfm_send/2379. I support ACTA so long as it and...

3 hours ago by Moley on ACTA: Facts, misconceptions and questions
45283

I think WinRT is fantastic. I just wish it was an option for people that didn't want to go through Microsoft's App Store with its attendant...

6 hours ago by 45283 on Why Windows 8 needs architectural hygiene for WOA
Burn-IT

Nine people? £30m? Who's back pocket is that lot going in? And IF they say it is for new buildings, what about all the ones the government has...

7 hours ago by Burn-IT on Police set to launch three £30m e-crime hubs
ewallace

Just to be clear, nobody knows what is in the text of ACTA, here is a photograph of the text of ACTA http://twitpic.com/8h9iju as submitted to the...

7 hours ago by ewallace on ACTA: Facts, misconceptions and questions
fgvrg56

Unfortunately main issue is that ASUS is refusing to accept that they make some mistake on this version of asus Transformer prime. 1 - GPS sensor...

8 hours ago by fgvrg56 on Asus Eee Pad Transformer Prime Wi-Fi & GPS problems?
Ben Woods

@Marcus A fair question. Just talked with Archos which said it was working on an announcement for next week....

9 hours ago by Ben Woods on Archos confirms G9 Ice Cream Sandwich update schedule
Marcus Karlsson

Any update on this, considering the claimed "first week of February"?

10 hours ago by Marcus Karlsson via Facebook on Archos confirms G9 Ice Cream Sandwich update schedule
apexwm

Bill Goodrich : Just as al_langevin pointed out, with Windows Server 2008 there is no Services for Macintosh anymore. It's gone, not available....

19 hours ago by apexwm on Windows Server 2008 drops the ball for Mac compatibility
txtrainguy

Replying to an old topic that I'm currently facing with my CEO (who is on a Mac). Our servers are primarily Windows Servers, office is about...

1 day ago by txtrainguy on Windows Server 2008 drops the ball for Mac compatibility
k0tcs3

Sure, that makes perfect sense. Pay wrong-doers money and thank them for breaching your security and pointing out your flaws, that would surely...

1 day ago by k0tcs3 on US indicts Romanian over NASA climate change hack
Random_Error

I think he's referring specifically to Android apps, as Apple do regulate their App Store, but Google seem to let any old crap onto the Android store!

1 day ago by Random_Error on RIM: BlackBerry will keep 'garbage' apps out of store
Paul Fezziwig

Keep the crap apps out?! How will they compete with Android and Apple's claim to fame of having so many life changing apps? I wonder if the media...

1 day ago by Paul Fezziwig via Facebook on RIM: BlackBerry will keep 'garbage' apps out of store
Aigars Mahinovs

It has been shown time after time that if there is an author store that sells the songs at even 1$ per song and gives you a high-quality digital...

1 day ago by Aigars Mahinovs via Facebook on Copyright isn't working, says European Commission