This directory contains little sample ASP.NET pages.
About Web Services samples
Summary of files:
TestService.asmx: A simple web service
ConverterService.asmx: Currency converter web service
DumpExtension.cs: Soap extension that dumps all requests to a file.
EncryptExtension.cs: Soap extension that encrypts all requests.
TraceExtension.cs: Soap extension that logs the soap messages.
ServiceClient.cs: Simple web service client
Reference.cs: Web service client proxies.
ServiceClient.exe.config: Configuration file for ServiceClient.
There are two sample web services, implemented in TestService.asmx and
TestService.asmx is a very simple web services with two methods. It shows how
simple is to implement web services using ASP.NET.
The ConverterService implements a simple currency converter. With it you can
make conversions between a limited set of currencies, get a list of currency
rates, get the rate of a given currency or change the rate of a currency.
This sample shows most of the functionality you can get from ASP.NET
The service uses Soap headers to keep information about the currently logged
user. Before calling any other method, the client must call Login(). This
method generates an Out header with user information that is sent and stored
in the client. All subsequent calls will include that header so the server
will be able to validate the user.
This WS also makes extensive use of Soap extensions. There are three of them:
- DumpExtension (DumpExtension.cs): This is a global extension that must be
configured in the web.config file. It dumps all requests and responses to
the file dump.log. It will only dump the calls of classes that have the
- EncryptExtension (EncryptExtension.cs): This extension uses the Rijndael
algorithm to encrypt all information exchanged between the server and the
client. For it to work, the web service class must have the [Encrypt]
attribute. The client proxy class used to connect to the service must also
have that attribute (see Reference.cs). This is also a global extension
that must be configured in web.config.
- TraceExtension (TraceExtension.cs): This extensions logs the soap requests
and responses to the file trace.log. The difference between TraceExtension
and DumpExtension is that TraceExtension logs requests after it's been
deserialized, so it can log the method name and parameter types and values.
On the other hand DumpExtension just does a raw dump of the received stream.
Another difference is that TraceExtension can be applied to individual
methods, using the attribute [TraceExtension].
In the client side, the client proxies are implemented in Reference.cs.
There is a sample client implemented in ServiceClient.cs that makes some calls
to the services.
How to test
Build XSP and start the server as usual.
cd to xsp/test and run ServiceClient.exe passing the hostname and port:
mono ServiceClient.exe localhost:8080
After execution, you should see the files trace.log and dump.log in
xsp/server/test with the traces of the requests. You can try to add and remove
the encrypt extension from web.config and ServiceClient.exe.config and see
in dump.log the information being sent in each case.