However it’s possible to test your WCF services using unit test by just referencing your service implementation (see Ploeh’s Blog) You gain a lot of benefit if you use the WCF infra structure to test your services.
For Example, did you ever get the error message during integration test (or worse, production) because your message couldn’t be serialized because of a null value. This wouldn’t happen if your unit test were using WCF. Espacially when you have large messages with a lot of elements.
See Howard’s blog how to implement this.
In the old days of ASMX webservices it was very easy to distribute the wsdl file of your service to other people, for example if you develop a service that’s not available to that person yet. The only thing you had to do was browse to http://myserver/mywebservice.asmx?wsdl and save the result of it. But nowadays the wsdl provided by your wcf service contains multiple files, the wsdl files uses import elements to include these file in the wsdl.
If you use svcutil.exe, wsdl.exe or some other tool to create a webservice client and reference a webservice directly this doesn’t matter. But this week I had to distribute my wsdl file and my service isn’t published yet. The only option was to download the wsdl file and each included file by hand.
After some searching for a neat solution I found a blog post by Mike Hadlow for downloading a wsdl and all included files to local disc. His solution makes use of the DiscoveryClientProtocol class in the .Net framework. This piece of code downloads all files but leaves the references of the xsd files pointing to the original url of the service. But this was also easy to solve. The WriteAll method of the DiscoveryClientProtocol class also creates a information file with the original location and the new filename. The only thing that has to be done is to replace the original urls with their local values.
Wsdl Download Executable
Wsdl Download source code
createUnfortunaly Silverlight 2 didn’t ship with any utility to generate a proxy class from the command line. Generating service proxy classes as service reference isn’t the way to go for me. Michael Giagnocavo wrote a little utility that makes use of a dll shiped with Silverlight to generate a proxy gut this one fails for me when I generate a little more complex proxy then HelloWorld. for example when I use multiple namespaces etc.
Read more…
The Entity Framework makes it very simple to implement Optimistic Concurrency Control (OCC). To use this feature in combination with a disconnected application (Website/webservices), the recommend practice is to send both the original and the updated values of the object. This causes much larger network requests and could be done much more elegant.
How to use Optimistic Concurrency Control in ADO.Net Entity Framework using Webservices or WCF
Optimistic Concurrency Control in Entity framework
For using OCC in the Entity Framework you’ve got 2 options:
- using Stored Procedures
- Set the Concurrency Property of an object.
Read more…