Tagged: Services
API tools, security 101, naming sites, javascript libraries
- A thorough listing of API tools @ API Evangelist Toolbox
- Breaker 101: An intensive online web security course
- How to Name Things – namely websites, using sites such Pun Generator and Werd Merge
- The Big Badass List of Twitter Bootstrap Resources
- JSDB.io: database of javascript libraries – but for some reason, paging doesn’t work after searching?
Asynchronous WCF calls without a generated proxy.
Like many other developers, I like to have control over the code I deploy. To enable asynchronous calls you normally have to generate the proxies with the option for asynchronous calls turned on. In the case where you have your own proxies; the ability to enable asynch calls is pretty simple.
You’ll likely have your standard synchronous interface as follows:
[ServiceContract]
public interface IFileService
{
[OperationContract]
FileResults GetFileConfig(FileRequest request);
}
To provide an asynchronous version simple create another interface; using the name alias against the service contract and asyncpattern set to true. Create a Begin and End pair of functions, post appended with the name of the operation you want to make synchronous.
[ServiceContract(Name=”IFileService”)]
public interface IAsyncFileService
{
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginGetFileConfig(FileRequest request, AysncCallback callback, object asyncState);
LoadConfigResults EndGetFileConfig(IAsyncResult result);
}
Now all your client has to do is is use the new Async interface and the server will resolve to an asynchronous operation.
public class FileServiceProxy : ClientBas<IAsyncFileService>, IAsyncFileService
{
IAsyncResult BeginGetFileConfig(FileRequest request, AysncCallback callback, object asyncState)
{
return Channel.BeginGetFileConfig(request, callback, asyncState);
}
…… // and the End call equivalent
}
Easy!