Xamarin的:系统.初始化WSDL ServiceClient时的InvalidOperationException

本文关键字:ServiceClient 时的 InvalidOperationException WSDL 初始化 系统 Xamarin | 更新日期: 2023-09-27 18:09:25

我正试图使Xamarin应用程序,这将通过WSDL的WCF与web服务一起工作。我有。wsdl文件和。cs文件由SvcUtil使用。wsdl文件生成。

当我做下一个:

ServiceClient _mobileService;
    public void Initialize()
    {
        var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential)
        {
            MaxReceivedMessageSize = long.MaxValue,
            MaxBufferSize = int.MaxValue,
            MaxBufferPoolSize = long.MaxValue,
            ReceiveTimeout = TimeSpan.FromMinutes(0.5),
            SendTimeout = TimeSpan.FromMinutes(0.5),
            OpenTimeout = TimeSpan.FromMinutes(0.5),
            CloseTimeout = TimeSpan.FromMinutes(0.5),
            ReaderQuotas =
            {
                MaxArrayLength = int.MaxValue,
                MaxBytesPerRead = int.MaxValue,
                MaxDepth = int.MaxValue,
                MaxNameTableCharCount = int.MaxValue,
                MaxStringContentLength = int.MaxValue
            },
            Security = {Mode = BasicHttpSecurityMode.Transport}
        };
        var endpoint = new EndpointAddress("https://ThereIsMySite/PathToService");
        _mobileService = new ServiceClient(binding, endpoint);
        _mobileService.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(1);

I got exception:

System.InvalidOperationException: Operation 'activateAsync' 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, Boolean isRpc, Boolean isEncoded) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.OperationFormatter..ctor (System.ServiceModel.Description.OperationDescription od, Boolean isRpc, Boolean isEncoded) [0x00000] in <filename unknown>:0 

然后我在控制台项目中尝试了相同的代码。Net 4.5),并且没有错误。

有知道如何使它在Xamarin上工作吗?

Xamarin的:系统.初始化WSDL ServiceClient时的InvalidOperationException

不幸的是,BasicHttpSecurityMode。TransportWithMessageCredential在Mono中还不支持,你可能想使用BasicHttpSecurityMode。当前运输

裁判:http://forums.xamarin.com/discussion/comment/44741/Comment_44741