Bug 46917 - Incorrect validation checks in message formater
Summary: Incorrect validation checks in message formater
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: master
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-13 13:06 UTC by Andoni Morales
Modified: 2017-09-06 16:55 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Andoni Morales 2016-11-13 13:06:50 UTC
The BaseMessagesFormater contains incorrect validation check for messages, throwing exceptions for a valid protocol like Onvif media service.

The Onvif WSDL defines the following protocol interface:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.onvif.org/ver10/media/wsdl", ConfigurationName = "Media.Media")]
public interface Media
{
        // CODEGEN: Parameter 'VideoSources' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'System.Xml.Serialization.XmlElementAttribute'.
	[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver10/media/wsdl/GetVideoSources/")]
	[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
	[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
	[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
	[return: System.ServiceModel.MessageParameterAttribute(Name = "VideoSources")]
	Onvif.Media.GetVideoSourcesResponse GetVideoSources(Onvif.Media.GetVideoSourcesRequest request);

	[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver10/media/wsdl/GetVideoSources/")]
	System.Threading.Tasks.Task<Onvif.Media.GetVideoSourcesResponse> GetVideoSourcesAsync(Onvif.Media.GetVideoSourcesRequest request);
}


Trying to call GetVideoSourcesAsync raise an InvalidOperationException

Unhandled Exception:
System.InvalidOperationException: Operation 'GetVideoSourcesAsync' contains a message with parameters. Strongly-typed or untyped message can be paired only with strongly-typed, untyped or void message.
  at System.ServiceModel.Dispatcher.OperationFormatter.Validate (System.ServiceModel.Description.OperationDescription od, System.Boolean isRpc, System.Boolean isEncoded) [0x0005a] in /opt/oneplay-build_darwin_darwin_x86_64/sources/darwin_x86_64/mono-4.6.0/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:79 
  at System.ServiceModel.Dispatcher.OperationFormatter..ctor (System.ServiceModel.Description.OperationDescription od, System.Boolean isRpc, System.Boolean isEncoded) [0x00006] in /opt/oneplay-build_darwin_darwin_x86_64/sources/darwin_x86_64/mono-4.6.0/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:55 
  at System.ServiceModel.Dispatcher.EndpointDispatcher.PopulateDispatchOperation (System.ServiceModel.Dispatcher.DispatchRuntime db, System.ServiceModel.Description.OperationDescription od) [0x00208] in /opt/oneplay-build_darwin_darwin_x86_64/sources/darwin_x86_64/mono-4.6.0/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs:178


I have created the following PR to fix it: https://github.com/mono/mono/compare/master...ylatuya:ws-client-fix?expand=1

Note You need to log in before you can comment on or make changes to this bug.