Problems with Web Service over HTTPS on Xamarin Studio

_Moe86__Moe86_ DEMember
edited October 2016 in Xamarin.iOS

After reading and coding the HelloWorldService example from the Xamarin walkthrough (Working with WCF) I thought it is easy to replace the Webservice with my own one. But I was wrong.

I followed all the steps from the guide and have generated a proxy with my own .wsdl file and the silverlight Service Model Proxy Generation Tool.
Now when I try to call a method from the WebService, for example a simple login, I get the following exception:

System.Net.WebException: There was an error on processing web request: Status code 400(BadRequest): Bad Request
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_delegate_end_invoke (object,intptr)
at (wrapper delegate-end-invoke) :end_invoke_object__this___object[]&_IAsyncResult (object[]&,System.IAsyncResult)
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.EndProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters, System.IAsyncResult result) [0x00025] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:460
at System.ServiceModel.ClientBase1+ChannelBase1[TChannel,T].EndInvoke (System.String methodName, System.Object[] args, System.IAsyncResult result) [0x0003c] in /Users/builder/data/lanes/3818/ad1cd42d/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:404

The strange thing is, when I try the same code as a Desktop App in Visual Studio 2015 it works like a charm.
With SoapUI the login worked as well (Windows and Mac).
Just on Xamarin Studio (Mac OS) it doesn't work. Is somebody familiar with this and can help me?

Here is a code snippet:

public static readonly EndpointAddress EndPoint = new EndpointAddress("https://[url]:[port]/Service1.asmx");
private Service1SoapClient _client;

public override void ViewDidLoad()
{
    base.ViewDidLoad();
    InitializeClient();
}

private void InitializeClient()
{
    System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };

    BasicHttpBinding binding = CreateBasicHttp();
    binding.Security.Mode = BasicHttpSecurityMode.Transport;

    _client = new Service1SoapClient(binding, EndPoint);
    _client.Ret_LoginCompleted += Client_Ret_LoginCompleted;
    _client.Ret_LoginAsync("user", "pwd");
}

void Client_Ret_LoginCompleted(object sender, Briloner.Ret_LoginCompletedEventArgs e)
{
    Console.WriteLine(e.Error);
    Console.WriteLine(e.Result);
}

private static BasicHttpBinding CreateBasicHttp()
{
    BasicHttpBinding binding = new BasicHttpBinding
    {
        Name = "basicHttpBinding",
        MaxBufferSize = 2147483647,
        MaxReceivedMessageSize = 2147483647
    };
    TimeSpan timeout = new TimeSpan(0, 0, 30);
    binding.SendTimeout = timeout;
    binding.OpenTimeout = timeout;
    binding.ReceiveTimeout = timeout;
    return binding;
}

Answers

Sign In or Register to comment.