【问题标题】:Xamarin: System.InvalidOperationException when Initializing WSDL ServiceClientXamarin:初始化 WSDL ServiceClient 时出现 System.InvalidOperationException
【发布时间】:2023-03-14 08:34:01
【问题描述】:

我正在尝试制作 Xamarin 应用程序,它将通过 WCF over WSDL 使用 Web 服务。 我有 SvcUtil 使用 .wsdl 文件生成的 .wsdl 文件和 .cs 文件。

当我下一步做时:

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);

我遇到了异常:

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 上运行?

提前致谢。

【问题讨论】:

标签: c# web-services wcf wsdl xamarin


【解决方案1】:

遗憾的是,Mono 中尚不支持 BasicHttpSecurityMode.TransportWithMessageCredential,您可能需要使用 BasicHttpSecurityMode.Transport 目前。

参考:http://forums.xamarin.com/discussion/comment/44741/#Comment_44741

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多