wcf: Exception when using proxy generated with the WCF Web Service Reference tool: There was an error reflecting 'data'

Hi,

When we try to use a specific connected service (soap) proxy class in a core 2.0 app, we receive an exception on calling any method from the class. (This service works fine in a .NET framework app)

It looks like the .net core class has been generated with several MessageBodyMemberAttribute that have a Namespace=“” which seem to be the cause of the error. I have included the wsdl and a sample .net core project.

The question we have is whether the problem is with the wsdl or is it a bug in the core WCF connected service tool?

Thanks,

Exception:

System.InvalidOperationException HResult=0x80131509 Message=There was an error reflecting ‘data’. Source=System.Private.Xml StackTrace: at System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) at System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess access) at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.XmlSerializerImporter.ImportMembersMapping(XmlName elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, Boolean isEncoded, String mappingKey) at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector.ImportMembersMapping(String elementName, String ns, XmlReflectionMember[] members, Boolean hasWrapperElement, Boolean rpc, String mappingKey) at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector.LoadBodyMapping(MessageDescription message, String mappingKey, MessagePartDescriptionCollection& rpcEncodedTypedMessageBodyParts) at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector.CreateMessageInfo(MessageDescription message, String key) at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.OperationReflector.EnsureMessageInfos() at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.EnsureMessageInfos() at System.ServiceModel.Description.XmlSerializerOperationBehavior.CreateFormatter() at System.ServiceModel.Description.XmlSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, ClientOperation proxy) at System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) at System.ServiceModel.Description.DispatcherBuilder.BuildProxyBehavior(ServiceEndpoint serviceEndpoint, BindingParameterCollection& parameters) at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose) at System.ServiceModel.ChannelFactory.OnOpening() at System.ServiceModel.Channels.CommunicationObject.<System-ServiceModel-IAsyncCommunicationObject-OpenAsync>d__79.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.ServiceModel.Channels.CommunicationObject.<OpenAsyncInternal>d__78.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.ServiceModel.ChannelFactory.EnsureOpened() at System.ServiceModel.ChannelFactory1.CreateChannel(EndpointAddress address, Uri via) at System.ServiceModel.ClientBase1.get_Channel() at CardManagementWS.CardManagementEPClient.loginAsync(String user, String password) in c:\users\com381\source\repos\msTestCaseShellWs\msTestCaseShellWs\Connected Services\CardManagementWS\Reference.cs:line 17459 at msTestCaseShellWs.Program.Main(String[] args) in c:\users\com381\source\repos\msTestCaseShellWs\msTestCaseShellWs\Program.cs:line 16

Inner Exception 1: InvalidOperationException: The top XML element ‘data’ from namespace ‘’ references distinct types CardManagementWS.WSIssueNewPayrollCardData and CardManagementWS.WSIssueNewPersonalizedPayrollCardData. Use XML attributes to specify another XML name or namespace for the element or types.

CardManagement.wsdl.txt Program.cs.txt

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

@RKDMax thank you very much for your quick and helpful response. I created a Web Request using WSDL and it worked successfully. 👍

@RKDMax Did you ever figure out a workaround for this? I’m attempting to use the same API with the same errors.

@joeytitans Unfortunately not. I had to make a separate .Net Framework project and consume the webservice the old way. My intent was that I could then take the results of those webservice calls and re-serve them up as my own Web API results which I could then consume in my .Net Core project.

Could you please clarify what do you mean by “.Net Framework project” and if possible the “old way” of service consumption you mentioned in your post. I am using .Net Framework web application wit .Net 4.6.1 in VS 2017 and get the same error as you.

Thank you in advance