Error using svcutil.exe to generate proxy classes from WCF service

While using svcutil.exe to generate proxy classes for a WCF client application, I got the following error:

C:\>svcutil.exe http://localhost:2338/MyService/Service.svc?wsdl
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'http://localhost:2338/MyService/Service.svc?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.XmlSerializerMessageContractImporter
Error: Object reference not set to an instance of an object.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://my.services']/wsdl:portType[@name='IMyService']
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://my.services']/wsdl:portType[@name='IMyService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://my.services']/wsdl:binding[@name='WSHttpBinding_IMyService']
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://my.services']/wsdl:binding[@name='WSHttpBinding_IMyService]
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://my.services']/wsdl:service[@name='MyService']/wsdl:port[@name='WSHttpBinding_IMyService']

Generating files...
C:\MyService.cs

I found this posting (See Hao Xu's post towards the bottom) suggesting that it is the difference between XmlSerializer and XmlFormatter.  Once I called svcutil.exe with the /serializer:XmlSerializer parameter, it generated my classes with no trouble.

Advertisements

One thought on “Error using svcutil.exe to generate proxy classes from WCF service

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s