使此WCF客户端代码在Mac上的Mono和MonoTouch上工

使此WCF客户端代码在Mac上的Mono和MonoTouch上工

本文介绍了使此WCF客户端代码在Mac上的Mono和MonoTouch上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使以下代码在Mono控制台应用程序中工作,并成为MonoTouch应用程序的最终目标.使用Windows控制台应用程序,该代码在VS2008下可以正常工作.在Mac上将其作为Mono控制台应用程序运行时,我得到

I am trying to get the following piece of code to work in a Mono console app and as the ultimate goal in a MonoTouch application. The code works fine under VS2008 using a Windows console app.When running it as a Mono console app on the Mac, I get

在MonoTouch中,我收到此错误:

In MonoTouch, I receive this error:

有人可以eplxain出什么问题了吗?没有涉及使事情变得简单的app.config.

Can somebody eplxain what is wrong? There is no app.config involved to keep things simple.

using System;
using MonoAPI3.BLAPI3Session;
using Brainloop.ServiceLibrary.DataModel;
using System.ComponentModel;
using System.ServiceModel;

public static void Main()
{
System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return true; };

var oClient = new SessionServiceClient( new BasicHttpBinding( BasicHttpSecurityMode.TransportWithMessageCredential )
            {
                CloseTimeout = new TimeSpan( 0, 0, 10 ),
                OpenTimeout = new TimeSpan( 0, 1, 0 ),
                ReceiveTimeout = new TimeSpan( 0, 1, 0 ),
                SendTimeout = new TimeSpan( 0, 1, 0 ),
                AllowCookies = false,
                BypassProxyOnLocal = false,
                HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                MaxBufferSize = 65536,
                MaxBufferPoolSize = 524288,
                MaxReceivedMessageSize = 65536,
                MessageEncoding = WSMessageEncoding.Text,
                TextEncoding = System.Text.Encoding.UTF8,
                TransferMode = TransferMode.Buffered,
                UseDefaultWebProxy = true,
                ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
                {
                    MaxDepth = 32,
                    MaxStringContentLength = 8192,
                    MaxArrayLength = 16384,
                    MaxBytesPerRead = 4096,
                    MaxNameTableCharCount = 16384
                }

            },
            new EndpointAddress( "https://service.myserver.com/Service/V3/Session.svc" ) );

            oClient.ClientCredentials.UserName.UserName = "[email protected]";
            oClient.ClientCredentials.UserName.Password = "pwd";

            SessionInfo oInfo = oClient.StartSession();

            Console.WriteLine( "SESSION HASH: " + oInfo.SessionHash );
}

推荐答案

问题所在的代码行是:

BasicHttpSecurityMode.TransportWithMessageCredential

Mono不支持WS-Security.基本上,BasicHttpSecurityMode上有很多选项无法使用.如果您需要消息凭证,那么恐怕此代码无法正常工作.这是一个相关的链接:

Mono does not support WS-Security. Basically there are many options on BasicHttpSecurityMode which will not work. If you require Message Credentials, then I'm afraid this code cannot be made to work. Here is a related link:

http://lists.ximian.com/pipermail/mono-bugs/2010-January/096972.html

这篇关于使此WCF客户端代码在Mac上的Mono和MonoTouch上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:28