question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dianakkcommented, Jul 10, 2020

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

1reaction
dianakkcommented, Jul 9, 2020

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

WCF generated proxy throws InvalidOperationException ...
I'm using Visual Studio 2013 to generate a WCF service proxy from this WSDL file. However, as soon as I try to call...
Read more >
Issues accessing Fault details in WCF client proxy ...
Fault details can't be accessed in client proxy generated by Visual Studio 2010 if the FaultContract detail is an array. This is a...
Read more >
Troubleshoot references to WCF or WCF Data Services
When you step into the code for a WCF service from client code, you may receive an error related to missing symbols. It...
Read more >
Client-Side Programming - Programming WCF Services ...
As an alternative to Visual Studio 2010, you can use the SvcUtil.exe command-line utility to import the service metadata and generate a proxy....
Read more >
OpenGIS With .Net 2.0 And WCF
While using "add service reference" we get this error: Custom tool error: Failed to generate code for the service reference 'ServiceReference1'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found