Kristian Kristensen’s Blog


Exporting WSDL from WCF

Posted in Code, Microsoft, WCF by Kristian Kristensen on the November 26th, 2007

WCF brings many good stuff to service development. A lot of thought and care has been put into the stack to ensure that it is flexible and future proof. Given that it is new and involves a lot of rethinking it also implies that it might do things differently than previous stacks.

One such change is in the generation of the WSDL from a service. Assuming that we have a service bound to the endpoint http://localhost/MyService we could obtain the WSDL for this service by hitting http://localhost/MyService?wsdl. By default his WSDL will be split up into separate files containing the necessary information to describe the services operations and input/output. This is pretty neat since it makes it more human readable than one big file containing everything. So far so good.
Another web service implementation from Microsoft is ASP.NET Web Services or ASMX. It uses/used the latter method of WSDL publication: one big file. So did other stacks. Recently I had to make a client built using Delphi 7 use a service from WCF. The built in web service stack in Delphi prefers/requires that the WSDL is contained in one file. If it is not it cannot generate a proxy class, and cannot communicate with the service. There is a discussion of the issue by one of the Delphi 7 developers here. He recommends either flattening the WSDL (ie. include all the WCF generated files in one big file), or use RPC encoded services.. The latter option isn’t really an option in my current context, so I looked at how to flatten the WSDL. Of course I’m not the only one with this request, so a quick Google search reveals a number of solutions:

Using Weyer’s FlatWSDL class I was able to generate a Delphi proxy class. However, I still couldn’t call my methods. The reason was that my contract is specified in an interface.
Tomas Restrepo writes:

This will not get rid, however, of any wsdl that WCF might be generating, such as the case when the service implementation and the service contract interface are in different namespaces.

My problem exactly. So if I remove my interface based services, and use plain classes, I can call my service operations. So far so good. But I still have one problem, the Delphi generated SOAP request is somehow not recognized by WCF. The correct operation gets called, but the parameters are not transferred correctly.

So where do I stand? I’ve flattened my WSDL for backwards compatibility. But my Delphi (dare I say legacy) client still cannot call my operation. I think that my next step is to convert my service into a POX service, and expose it via some kind of plain RPC. It doesn’t get any simpler than that, and this method should be supported by any type of client. If all else fails you can handcraft the request XML yourself and POST it to the service.

4 Responses to 'Exporting WSDL from WCF'

Subscribe to comments with RSS or TrackBack to 'Exporting WSDL from WCF'.


  1. on November 28th, 2007 at 2:54 pm

    Kristian,

    The problem with your separate WSDL files is not that you have an explicit service contract (i.e. interface) defined; it’s that the service contract and the service implementation have different namespaces.

    You can force them to use the same namespaces using the WCF attributes to resolve the issue without having to forgo explicit service contracts. For example, you can manipulate the XML namespace associated with a contract using the Namespace property of the [ServiceContract] attribute.


  2. on November 28th, 2007 at 10:21 pm

    Ah I see maybe I should try that out.
    I’ve been having some issues in connecting a Delphi 7 client to a WCF service exposed over a basicHttpBinding. The body of the envelope from Delphi has some different namespace declarations than a std WCF client. The XML looks correct, but for some reason WCF fails to deserialize it. I haven’t found a solution, but’ll post it if or when I do.

    Thanks for your comment and clarification!

  3. bob said,

    on December 6th, 2007 at 7:13 am

    just download the updated wsdl importer from http://cc.borland.com/Item.aspx?id=24535&

  4. bob said,

    on December 6th, 2007 at 7:14 am

    get delphi update at http://cc.borland.com/Item.aspx?id=24535&

Leave a Reply

You must be logged in to post a comment.