5
votes

I have a Silverlight application that is communicating with ADO.Net data entities on the server side through a WCF Service. Actually, I am using multiple WCF services to communicate with three different data ADO.Net data entities. I had originally constructed this project on Visual Studio 2010, and recently moved to Visual Studio Professional 2012 (trial version) about a week ago. Everything worked/ported fine initially and I had no issues with the services about until about an hour ago. I was literally using these same WCF services in my code less then an hour ago. However, when I added a method to insert an xml string into my data base I got this error:

Content Type text/xml; charset=utf-8 was not supported by service . The client and service bindings may be mismatched.

But I checked the bindings and they were basicHttpBinding as far as I could tell from the ServiceReferences.ClientConfig file. I looked around for a solution and the only one I could find suggested deleting the service reference and reading it after restarting Visual Studio, so I finally tried that, but now, even after removing the method I had added, I now get this error when I try to add a service reference on the Client:

Warning 6   Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Exception has been thrown by the target of an invocation.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IXMonitorXMLDataService']    C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1


Warning 7   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://tempuri.org/']/wsdl:portType[@name='IXMonitorXMLDataService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_IXMonitorXMLDataService']    C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

Warning 8   Custom tool warning: 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://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_IXMonitorXMLDataService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='XMonitorXMLDataService']/wsdl:port[@name='BasicHttpBinding_IXMonitorXMLDataService']  C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

Warning 9   Custom tool warning: No endpoints compatible with Silverlight 5 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.  C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

Warning 10  Custom tool warning: Exception has been thrown by the target of an invocation.  C:\Users\ckarrs\Documents\Visual Studio 11\Projects\SL_xMonitor_Frontend_RefactorV1_Backup82212\SL_xMonitor_Frontend_RefactorV1\Service References\XMonitorXMLDataService\Reference.svcmap  1   1   SL_xMonitor_Frontend_RefactorV1

I am so confused. The other service references remain the same, and this service was working completely until I tried to add to it and update the reference. Is this a compatibility issue between VS 2010 and 2012? The MSDN website says VS 2012 is backwards compatible with VS 2010 and everything seemed to migrate fine. Any help is greatly appreciated, I am perplexed. Please let me know if additional info is required.

1
Please show us the OperationContract you added. I bet it uses .NET types which are not supported in Silverlight.John Saunders
It will be helpful if you can post a piece of repro code. Thanks, PraburajPraburaj
I'm interested to see the answer to this one, as well. I saw the same problem with a non-silverlight application trying to consume a service from an asp.net asmx service.dodexahedron
hi, sorry, I have been feeling swamped with work and unable to post, but I will try and post the requested OperationContract and code tonight. Also, I have not had issues with it since making sure to uncheck the "Reuse types in all referenced assemblies" box under advanced settings when adding a Service Reference. It seems to be some issue with the reuse of types.Christian

1 Answers

1
votes

I am not an expert on WCF, but i know about .net web services and WSDL, so please correct if the information is not relevant to WCF.

The error says: An exception was thrown while running a WSDL import extension. This means, that VS was not able to read the service WSDL file properly, and was not able to create the proxy client class it needs, in order to make the service calls.

Because an .net application with a reference to a web service will automatically get the WSDL, and sometimes it is not what it expects, this can cause trouble. there is a way to configure how the WSDL file is generated, but is is not so easy to do (read more here)

try to get the WSDL file by typing ?wsdl query after the service URL in a browser and see what is inside. If the server is behind a proxy server, this can cause problems. At the end of the WSDL file you will find the 'binding', 'endpoint', and 'port' tags/attributes.

According to the error message you have posted, the WSDL is not according to the expected schema, and parsing failes.

An easy workaround is, if you have access to the server, to save the generated WSDL file in the same directory, where the service is, modify the WSDL file according to what you need, and add a reference to the modified WSDL file in your client application. Of course this has a side-effect that the file is out of sync each time you change the service definition. so if you plan to change the methods a lot in future, maybe better is to alter/Fix the automatic WSDL generation.