Cannot import wsdl:portType

Here’s something that took a lot longer than it should have. I wanted to try out the Bing Translator API in a Windows Phone application. Easy, yes? Well, quite easy actually after one thing that caused a huge amount of trouble.

So, to use the API in my WP application, I first need to add a service reference to the Bing Translator API. Adding a service reference is quite easy, just right-click on the project name and select “Add Service Reference…”. Set the address to http://api.microsofttranslator.com/V2/Soap.svc and press Go. Visual Studio will find the service and after specifying a namespace (TranslatorService in my case) and pressing OK the service reference will be added.

HOWEVER.

The problem

In my case what happened was that I started getting weird warnings and errors, like the ones below:


Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load type 'System.Runtime.Serialization.DataContractSet' from assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://api.microsofttranslator.com/V2']/wsdl:portType[@name='LanguageService']


Custom tool warning: 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://api.microsofttranslator.com/V2']/wsdl:portType[@name='LanguageService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_LanguageService']

And finally compiling the project failed with the following error:

Custom tool error: Failed to generate code for the service reference 'TranslatorReference'. Please check other error and warning messages for details.

Great. The compiler output is not very helpful (at least for me), and for some reason Internet wasn’t very helpful either.

The solution

After a lot of head-scratching I stumbled upon popup menu entry “Update service reference”. After clicking on that Visual Studio did something and the errors disappeared. I still don’t really know what the problem was and how it got fixed, but at least everything works now. 🙂

One Response to Cannot import wsdl:portType

  1. Ritu says:

    Thanks a lot for the solution.

Leave a comment