Setting Wrapped property on WCF Messages

Topics: General Discussion Forum, Service Factory Modeling Edition Forum
Feb 12, 2008 at 3:27 PM
I recently went through a huge deployment challenge with some WCF services, specifically during the generation of the proxy classes. I was getting a lot of symptoms, the most common of which was:

Attempting to download metadata from 'http://localhost/testhost/contactservice.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: Unable to cast object of type 'System.Xml.Serialization.StructMapping' to type 'System.Xml.Serialization.MembersMapping'.
XPath to Error Source: //wsdl:definitions@targetNamespace='urn:PaymentsNation.NSS'/wsdl:portType@name='ContactService'

This error is not ANYWHERE on Google, which of course, made it very challenging to figure out. Ultimately through tweaking and comparison of WSDLs we discovered that the culprit was a message contract that was not wrapped. This message contract validates and generates just fine because it only has one property, but it will not generate proxy code very well.

We did solve this problem by making sure that ALL message contracts were wrapped regardless of parameter count. I just wanted to post this revelation in the hopes of saving someone else headaches down the road.

Feb 28, 2008 at 3:33 PM
We were running up against the same, very frustrating, problem.

It seems that when using svcutil the rule is that "If you wrap the response, then you have to wrap the request if the request has only one property."

At least that's how it working for us when we use svcutil.

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\svcutil.exe" /serializer dataContractSerializer /noLogo /noConfig /s /ct ystem.Collections.Generic.List`1 /language:csharp /n:*,ServiceReferences.TestService /out:"SimpleService.cs" "http://localhost:2668/SimpleService.svc"

Jan 29, 2009 at 2:33 PM

I am very new to the WSSF. I have gone through the HOL and read a few other things but I still don't really have a clear understanding of what needs to be done. I am at the point where I need to create the XSD for a Response XSD Message in my Service Model. I understand that, per the documentation, the XSD needs to be compatible with Data Contract and that utilizing the svcutil.exe will assist me in this endeavor. However, I don’t know what file to point to. The post above is using an .svc file. I have no idea where that would be. I only have the service and data contract files that VS creates. Can someone please point me in the right direction?


Jan 29, 2009 at 4:17 PM
You can use scvutil against your contract classes (service contract or data conttract) or simple end up creating the service host project that will generate the .svc file.
For the latter you can use WSSF host designer once you have your service contract and data contract projects.