小编ant*_*ode的帖子

MonoTouch WCF REST错误创建频道

我正在尝试通过MonoTouch访问WCF REST服务.我无法使用ChannelFactory,因为在MonoTouch中无法生成动态代码,并且因为我正在访问RESTful服务,所以我也无法使用svcutil来构建客户端类.

这让我手动构建客户端类.我已经走了很远,但遇到了问题,这是代理类的代码:

public class AuthenticationClient : System.ServiceModel.ClientBase<IAuthenticationService>, IAuthenticationService
{
    public AuthenticationClient(Binding binding, EndpointAddress baseAddress) : base(binding, baseAddress)
    { } 

    public AuthenticationResult AuthenticateUser (AccountCredentials credentials)
    {
        return base.Channel.AuthenticateUser(credentials);
    }

    protected override IAuthenticationService CreateChannel ()
    {
        // This method must be overriden in MonoTouch to prevent using a ChannelFactory
        return new AuthenticationChannel(this);
    }

    private class AuthenticationChannel : ChannelBase<IAuthenticationService>, IAuthenticationService
    {
         public AuthenticationChannel(System.ServiceModel.ClientBase<IAuthenticationService> client) : 
            base(client)
        { }

        public AuthenticationResult AuthenticateUser (AccountCredentials credentials)
        {
            object[] _args = new object[1];
            _args[0] = credentials; …
Run Code Online (Sandbox Code Playgroud)

rest mono wcf channelfactory xamarin.ios

5
推荐指数
0
解决办法
1118
查看次数

标签 统计

channelfactory ×1

mono ×1

rest ×1

wcf ×1

xamarin.ios ×1