1

Good day, everyone!

I have an issue: I have a WCF service. Also I have a Xamarin.Forms app, that connects to the server. First time i did it using slsvcutil.exe, but the solution seems to be not really suitable, it was built on events, because of that there were a lot of events and the code was hardly readable. When I tried to do it via ChannelFactory, it worked for Android. Right nowthere are no problems with Android, but for iOS it's ot working at all because of CreateChannel() method. I did another class with ChannelBase using these links:

first link, second link,

and error dissapears. But it just not connecting to my WCF service... Trying to connect for several days, but still nothing... Maybe any chances to do it in another way? Any help would be appreciated.

p.s. The code for my iOS interface and class:

public class NewClassForConnectionIOS : ClientBase<IAis7MobileIssoSServerCoreXamarin>, IAis7MobileIssoSServerCoreXamarin
    {

        public NewClassForConnectionIOS() : base() { }

        public NewClassForConnectionIOS(Binding binding, EndpointAddress endpointAddress) : base(binding, endpointAddress) { }

        public NewClassForConnectionIOS(string endpoint) : base(endpoint) { }


        public string[] HttpsGetSessionIdForIssoS(string user, string pass)
        {
            return ((NewClassForConnectionChannel)base.Channel).HttpsGetSessionIdForIssoS(user, pass);
        }

        public IAis7MobileIssoSServerCoreXamarin CreateConnection()
        {
            return CreateChannel();
        }

        protected override IAis7MobileIssoSServerCoreXamarin CreateChannel()
        {
            return new NewClassForConnectionChannel(this);
        }

        private class NewClassForConnectionChannel : ChannelBase<IAis7MobileIssoSServerCoreXamarin>, IAis7MobileIssoSServerCoreXamarin
        {
            public NewClassForConnectionChannel(ClientBase<IAis7MobileIssoSServerCoreXamarin> client) : base(client) { }

            public string[] HttpsGetSessionIdForIssoS(string user, string pass)
            {
                return (string[])base.Invoke("HttpsGetSessionIdForIssoS", new object[] { user, pass });
            }

            //public IAsyncResult BeginHttpsGetSessionIdForIssoS(string user, string pass, AsyncCallback callback, object asyncState)
            //{
            //    object[] _args = new object[2];
            //    _args[0] = user;
            //    _args[1] = pass;
            //    return (IAsyncResult)base.BeginInvoke("HttpsGetSessionIdForIssoS", _args, callback, asyncState);
            //}

            //public string[] EndHttpsGetSessionIdForIssoS(IAsyncResult asyncResult)
            //{
            //    object[] _args = new object[0];
            //    return (string[])base.EndInvoke("HttpsGetSessionIdForIssoS", _args, asyncResult);
            //}
        }
    }

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName ="IAis7MobileIssoSServerCoreXamarin")]
    public interface IAis7MobileIssoSServerCoreXamarin
    {
        [System.ServiceModel.OperationContractAttribute(Action = "HttpsGetSessionIdForIssoS", ReplyAction = "http://tempuri.org/IAis7MobileIssoSServerCoreXamarin/HttpsGetSessionIdForIssoSResponse")]
        string[] HttpsGetSessionIdForIssoS(string user, string pass);
    }
  • Hi @Денис Чорный ! I have the same situation here, but I get ChannelBase does not contain a definition for Invoke! Do you get that error with last version? Thanks! – Ignacio Sep 16 '18 at 18:47
  • Hello @Ignacio! No, I don't. As you can see my answer, the above question is a working solution. Right now I have a separate class for iOS, that inherits from the `clientBase` class and includes a class that inherits from `ChannelBase`, so almost like in a code above. – Денис Чорный Sep 17 '18 at 09:53
  • Hello again @Денис Чорный! I´m using .Net Standard 2.0 that is why Invoke (...) is not available. What I have done (for others in the same situation) is regenerated the Connected Service Reference file with svcutil in the version of Visual Studio 15.8.1 with this command svcutil /async /tcv:Version35 https://... then using this on the sync methods: var iar = BeginInvoke("YourMethod", _args, null, null); return (string)EndInvoke("YourMethod", Array.Empty(), iar);. – Ignacio Sep 17 '18 at 11:28

1 Answers1

0

If that would be interesting for somebody, I have resolved that issue. As I mentioned, I didn't have a connection from my iOS device to my WCF service. And after days of searching the info, I tried to connect via physical Android device, not an emulator, and it didn't connect too!

So I investigated, that windows turned on my windows defender.... Lame mistake. After disabling that everything works perfect!

If you'll have such a mistake, please, check your connection from remote device! Hope that will help someone.