The FileService sample demonstrates the basic use of the Web Services for Devices API. FileService implements the functionality described by FileService.wsdl. The sample includes both a client and service.
|ReadMe.txt||This readme file|
|FileServiceContract\CodeGen_All.config||Config file for this sample|
|FileServiceContract\CodeGen_Client.config||Alternate config file (see note below)|
|FileServiceContract\CodeGen_Host.config||Alternate config file (see note below)|
|FileServiceService\Service.h||Header for Service Implementation|
|FileServiceClient\Client.h||Header for Client Implementation|
These files are generated automatically by WsdCodeGen.exe, but are included in the sample for reference. You may rebuild these files by running WsdCodeGen.
|FileServiceContract[FileService.h]||Header file built from FileService.idl|
|FileServiceContract\FileServiceProxy.cpp||Proxy class implementations|
|FileServiceContract\FileServiceProxy.h||Proxy class definitions|
|FileServiceContract\FileServiceStub.cpp||Stub function implementations|
|FileServiceContract\FileServiceTypes.h||Type declarations and structure definitions|
- Windows Vista
- Windows Server 2008
- Windows 7
- Windows Server 2008 R2
Running the server and client applications
To build, type nmake on the command line in this directory. The client and service applications can run on the same Microsoft Windows Vista computer or a different one.
To run the service type:
FileServiceService.exe <path> (where <path> is the folder of files to be served)
To run the client type:
FileServiceClient.exe <path> <device ID> (where <path> is the folder to receive files and <device ID> is the ID printed by FileServiceService.exe)
Layout of classes and functions
Service classes and functions
||Starts and makes a blocking request for file change notifications. When a notification is received, this class packages up the results and sends an event to all subscribed clients.|
||Opens a file and writes all data in the file into the supplied attachment object. When the file has been completely consumed, the object will close the attachment and then delete itself. The proper way to use this object is to instantiate one, call Start, and then discard the pointer to the object. It will be responsible for its own cleanup.|
||Removes path information from a filename.|
||Copies a string into a new buffer allocated with
||Copy a string into a
||Main function for processing command-line arguments and building a device host which advertises a
Client classes and functions
||Notification class that receives callbacks when a host sends a FileChange event to this client. This object is passed in as a parameter when the client subscribes to the FileChange event.|
||Notification class that is used when the client calls the
||Wrapper function that invokes the
||Wrapper function that sets up a
||Main function for processing command-line arguments, creating a proxy for sending service messages to a
Alternate Codegen Config Files
Three config files are included with this sample.
- CodeGen_All.config: Default, includes both host and client options
- CodeGen_Client.config: Client-only options
- CodeGen_Host.config: Host-only options
Only the first of these (CodeGen_All.config) is used when generating code for the FileService sample. CodeGen_Client.config and CodeGen_Host.config are provided to illustrate how to generate code for only the client and only the host.
If you would like to use these alternate config files, follow these steps:
WsdCodeGen.exe /generatecode [alternate config file] /gbc.
- Rebuild the
FileServiceContractproject, and then rebuild either the