Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-generated client code may use incorrect type #5412

Open
jflevesque-genetec opened this issue Jan 29, 2024 · 3 comments
Open

Auto-generated client code may use incorrect type #5412

jflevesque-genetec opened this issue Jan 29, 2024 · 3 comments
Labels

Comments

@jflevesque-genetec
Copy link

jflevesque-genetec commented Jan 29, 2024

Describe the bug
When generating client implementation from https://www.onvif.org/ver10/advancedsecurity/wsdl/advancedsecurity.wsdl, the generator generates incorrect code. If you look at the following line:
https://github.com/jflevesque-genetec/wcf/blob/2d051c83b3f141ab6dddf51aeb4ce3477981e228/ClassLibrary1/Connected%20Services/ServiceReference1/Reference.cs#L8277
the type specified in the attribute is incorrect. It should have been typeof(DNAttributeTypeAndValue[])

To Reproduce
Sample: https://github.com/jflevesque-genetec/wcf

Callstacks:
System.ServiceModel.CommunicationException: There was an error in serializing body of message GetAllCertPathValidationPoliciesRequest: 'CodeGenError(IsNotAssignableFrom): Cannot convert source type [ServiceReference1.DNAttributeTypeAndValue[]] to target type [ServiceReference1.DNAttributeTypeAndValue].'.  Please see InnerException for more details.
 ---> System.InvalidOperationException: CodeGenError(IsNotAssignableFrom): Cannot convert source type [ServiceReference1.DNAttributeTypeAndValue[]] to target type [ServiceReference1.DNAttributeTypeAndValue].
 ---> System.Xml.Serialization.CodeGeneratorConversionException: CodeGenError(IsNotAssignableFrom): Cannot convert source type [ServiceReference1.DNAttributeTypeAndValue[]] to target type [ServiceReference1.DNAttributeTypeAndValue].
   at System.Xml.Serialization.CodeGenerator.InternalConvert(Type source, Type target, Boolean isAddress)
   at System.Xml.Serialization.SourceInfo.InternalLoad(Type elementType, Boolean asAddress)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElement(SourceInfo source, ElementAccessor element, String arrayName, Boolean writeAccessor)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElements(SourceInfo source, String enumSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, String arrayName, Boolean writeAccessors, Boolean isNullable)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteArrayItems(ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc arrayTypeDesc, String arrayName, String choiceName)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElement(SourceInfo source, ElementAccessor element, String arrayName, Boolean writeAccessor)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteElements(SourceInfo source, String enumSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, String arrayName, Boolean writeAccessors, Boolean isNullable)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteMember(SourceInfo source, String choiceSource, ElementAccessor[] elements, TextAccessor text, ChoiceIdentifierAccessor choice, TypeDesc memberTypeDesc, Boolean writeAccessors)
   at System.Xml.Serialization.XmlSerializationWriterILGen.WriteStructMethod(StructMapping mapping)
   at System.Xml.Serialization.XmlSerializationILGen.GenerateReferencedMethods()
   at System.Xml.Serialization.XmlSerializationWriterILGen.GenerateEnd()
   at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] xmlMappings, Type[] types)
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location)
   at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.ServiceModel.Description.XmlSerializerHelper.FromMappingsViaReflection(XmlMapping[] mappings, Type type)
   at System.ServiceModel.Description.XmlSerializerHelper.FromMappings(XmlMapping[] mappings, Type type)
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.CreateSerializersFromMappings(XmlMapping[] mappings, Type type)
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GenerateSerializers()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32 handle)
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerStub.GetSerializer()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_BodySerializer()
   at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
   --- End of inner exception stack trace ---
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
--- End of stack trace from previous location ---
   at ClassLibrary1.Class1.<>c__DisplayClass0_0.<<Test>b__0>d.MoveNext() in C:\Genetec\github\wcf\ClassLibrary1\Class1.cs:line 37
--- End of stack trace from previous location ---
   at FluentAssertions.Specialized.AsyncFunctionAssertions`2.NotThrowAsync(String because, Object[] becauseArgs).
   at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message)
   at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
   at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)
   at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
   at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
   at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args)
   at FluentAssertions.Specialized.DelegateAssertionsBase`2.NotThrowInternal(Exception exception, String because, Object[] becauseArgs)
   at FluentAssertions.Specialized.AsyncFunctionAssertions`2.NotThrowAsync(String because, Object[] becauseArgs)
   at ClassLibrary1.Class1.Test() in C:\Genetec\github\wcf\ClassLibrary1\Class1.cs:line 39
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_0.<<InvokeTestMethodAsync>b__1>d.MoveNext() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs:line 285
--- End of stack trace from previous location ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in /_/src/xunit.execution/Sdk/Frameworks/ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 90

WSDL: https://www.onvif.org/ver10/advancedsecurity/wsdl/advancedsecurity.wsdl

Expected behavior
Auto-generated code to work out of the box.

Additional context
To reproduce, simply run the Test method in Class1.cs

@HongGit
Copy link
Contributor

HongGit commented Jan 31, 2024

@imcarolwang can you please try to repro this? Also, please try to see if this works with svcutil.exe.

@imcarolwang
Copy link
Contributor

The problem could be reproduced, and code generated by svcutil.exe behaves the same.

@GillesTourreau
Copy link

I have the same issue as @jflevesque-genetec with one of the Workday webservices (https://community.workday.com/sites/default/files/file-hosting/productionapi/Human_Resources/v41.0/Human_Resources.wsdl).

This issue exists with the version 2.2.0-preview1.23462.5 and the version 2.1.0 of the dotnet-svcutil tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants