WCF, WSDL and differences from web services

· August 5, 2008

I’m back after a four week vacation (oh yeah - us Swedes really has things going for us). More about the vacation later. First thing to learn this “season” is that the WSDL generated by WCF (Windows Communication Foundation) services differs from the one generated with ASMX web services.

The main difference is that the WSDL is generated with some kind of virtual links. That is; parts of the WSDL-file is retrieved using a different URL. For example: schemaLocation=”http://localhost:3236/Bokforing.svc?xsd=xsd0

This seems to be working fine in Visual Studio 2008 (and hopefully in 2005 also), since they are capable of navigating such references. But there are problems when you want to send the WSDL-file to someone as an attachment, or in other environment that can’t navigate such links.

Fortunally Christian Weyer has a suggestion on how to solve this. There are also some other very useful stuff in there on how to use namespace correctly in the attributes of WCF.

Since I am forced to use VB.NET I translated the code using this excellent tool found at Developer Fusion

It is quite tricky but can all be done with base-classes so that not every developer in the team needs to worry about it…

Two gotchas appeared for me;

  1. The @ServiceHost Factory is a bit strange since is doesn’t show up in intellisense. It works quite fine though. Read more about it here, and here.
  2. The loop found in the private method RemoveXsdImports was quite tricky to translate into VB.NET since its using a kind of looping that not is supported by VB.NET. Also the Developer Fusion tool didn’t translate it correct. Here is the code:

    Private Sub RemoveXsdImports(ByVal schema As XmlSchema) Dim i As Integer = 0 While i <>

Twitter, Facebook