Symtons
Adding a WCF “Service Reference” in Visual Studio 2008, pointing at http://localhost/FooMessage?wsdl. All the different files are added in Solution Explorer. But investigation the Reference.cs beneath Service References –> ServiceReference1 –> Reference.svcmap –> Reference.cs (found if “Show All Files” is clicked in Solution Explorer) reveals that no code has been generated. No warnings, no nothing. The app.config doesn’t contain no endpoints or binding either.
Cause
I’ve tried to validate the wsdl with the step by step procedure found here http://webservices20.blogspot.com/2008/10/how-to-validate-your-wsdl.html. But the wsdl is “passed” as a legal wsdl. Using svcutil.exe gives me errors though:
C:\>svcutil http://localhost/FooMessage?wsdl
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'http://localhost/FooMessage?wsdl' using WS-Metadata Exchange or DISCO.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Object reference not set to an instance of an object.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://foo.facade.com/']/wsdl:portType[@name='SendFooMessage']
Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://foo.facade.com/']/wsdl:portType[@name='SendFooMessage']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://foo.facade.com/']/wsdl:binding[@name='SendFooMessagePortBinding']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://foo.facade.com/']/wsdl:binding[@name='SendFooMessagePortBinding']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://foo.facade.com/']/wsdl:service[@name='SendFooMessage']/wsdl:port[@name='SendFooMessagePort']
Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.
Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.
Here follows a days effort in trying to make adjustments to the wsdl. Which by the way isn’t mine. Trying to narrow done the different possibilities.
Workaround
To narrow the story down. It turned out to be the differences between XmlSerializer and XmlFormatter. If you use XmlSerializer (use SvcUtil option /serializer:XmlSerializer), it should work fine. Use a tool, svcutil with a switch, to generate the needed code.
svcutil http://localhost/FooMessage?wsdl /serializer:XmlSerializer
This generates two files for you, the SendFooMessage.cs og output.config.