We did an event a couple of days ago which linked together a few different UI
topics, namely;
- ASP.NET Web Forms V2.0
- Windows Forms V2.0 and Smart Client
- "Avalon" Introduction (it was still called "Avalon" when we did the
session, now it's called "Windows Presentation Foundation").
and we also dropped in a session about communication between applications
based around ASMX Web Services V2.0 and the features in the WSE 3.0 Technical
Preview.
For the web services session I built up a simple demo application to show
various features of ASMX 2.0 (particularly around custom serialization, generic
type support, basic profile compliance and the new interface based development
model). Aaron
documents all these really well :-)
For WSE 3.0 we showed how we can host ASMX web services over the TCP
transport, we also showed how we can use MTOM for binary and we showed the new
simplified security policy and (in particular) I used the username over X509
security settings to control access to perform authentication at my service and
to get my message some integrity and privacy.
For all of this, I used a simple app that we built up based around being able
to send MP3 files from a service back to a client and I had a few people ask me
whether they could have the app as we'd built it up on stage and so I'm
including it here.
Now, unfortunately, I deleted what I built on Wednesday shortly after
building it so I've had to rebuild here but it should be pretty much identical.
Two things to note - one is that it's just a sample and so, naturally, don't
assume that it's "best practise" or anything like that and the second is that
I've not applied the security settings that we used on Wednesday because it'd
probably make it too hard to get working on your machine in the first instance.
If you want to apply security then drop into the "WSE 3.0 Settings" dialog box
in VS 2005 and set up your security policy.
The zip file for download is here:
http://mtaulty.com/downloads/MusicClientDemo.zip
What's in the zip file? Firstly, there are 4 Visual Studio 2005 projects;
MusicLibrary - this is my limited little set of managed code that
does just enough work to let me read some MP3 file information from a bunch
of MP3 files in a single location. There's one important class called
Library and you construct that with the place where your music is and
then you can ask it to get you various information about those MP3 files
that it found.
MusicService - this takes the MusicLibrary and puts a web
service "facade" (rather grandiose term for what I actually did) on the
front of it. We then hosted this service both over HTTP with ASMX and over
TCP with WSE 3.0. This has a hardcoded path in it as to where the music
lives - "d:\music" so you'd need to change
that.
MusicClient - this is the Windows Forms application. Looks like
this;

You type in the "location" of your music (e.g. the HTTP URL
where the ASMX music service is configured or the TCP URI where the WSE 3.0
service is listening) and then click the "Go" button and it brings down the
rest for you - it's very basic!
ConsoleHostForAsmxTcpWithWse - a very simple console
application which hosts the MusicService ASMX web service over a TCP
transport by using WSE 3.0. By default, this does almost nothing and listens
on a hardcoded URI which is soap.tcp://localhost/myMusicService so
that would be one of the things to type into the "Location" box on the
client if you had that console service running.
The other thing in the zip file is a second ZIP. This is called
WebServerVirtualDirectoryFiles.zip. This is the stuff which hosts the
exact same MusicService web service over HTTP with IIS/ASP.NET.
Essentially, this is just an ASMX file, a config file and the two binaries (MusicLibrary.dll,
MusicService.dll) that are needed for the service. On my machine I created a
virtual directory in
c:\inetpub\wwwroot\demos and I dropped these files into there.
That's it - hopefully it's explanatory enough that you can make
use of it should you want to :-) Feel free to mail me if I can help with getting
it working.
Posted
Fri, Jul 29 2005 3:09 AM
by
mtaulty