Quick background info: There is a wcf with authentication which use BasicHttpBinding. The Dataservice.cs contains the dataserviceclient based on the service metadata (generated using svcutil).
I first made an console app using the code and it worked perfectly then I made an xamarin android project. I copied the code. referenced system.runtime.serialization and system.servicemodel. This gives me an The method or operation is not implemented error.
Main code:
base.OnCreate(bundle);
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
EndpointAddress address = new EndpointAddress("https://serviceurl/service1.svc");
PermissiveCertificatePolicy.Enact("CN=MySelfSignedCert");
var client = new DataServiceClient(binding, address);
client.ClientCredentials.UserName.UserName = "Username";
client.ClientCredentials.UserName.Password = "Passord";
try
{
var projects = client.GetDataTest(1);
}
catch (Exception ex)
{
var error = ex.Message;
}
I am new to Xamarin programming so I could be missing key point here, but please remember that this works as an console app and the service is online (not localhost).
Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
07-20 11:35:39.704 D/Mono ( 1452): DllImport attempting to load: '/system/lib/liblog.so'. 07-20 11:35:39.704 D/Mono ( 1452): DllImport loaded library '/system/lib/liblog.so'. 07-20 11:35:39.704 D/Mono ( 1452): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so'). 07-20 11:35:39.704 D/Mono ( 1452): Searching for '__android_log_print'. 07-20 11:35:39.704 D/Mono ( 1452): Probing '__android_log_print'. 07-20 11:35:39.704 D/Mono ( 1452): Found as '__android_log_print'. 07-20 11:35:39.708 I/MonoDroid( 1452): UNHANDLED EXCEPTION: 07-20 11:35:39.708 I/MonoDroid( 1452): System.NotImplementedException: The method or operation is not implemented. 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.BasicHttpBinding.CreateSecurityBindingElement () [0x00025] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding_4_5.cs:125 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.BasicHttpBinding.CreateBindingElements () [0x00006] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding_4_5.cs:98 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.Channels.CustomBinding..ctor (System.ServiceModel.Channels.Binding binding) [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CustomBinding.cs:60 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.Channels.Binding.CreateContext (System.ServiceModel.Channels.BindingParameterCollection parameters) [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs:96 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.Channels.Binding.CanBuildChannelFactory[TChannel] (System.ServiceModel.Channels.BindingParameterCollection parameters) [0x00011] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs:267 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ChannelFactory.CreateFactory () [0x000ad] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs:199 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ChannelFactory.OnOpening () [0x00006] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs:383 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.Channels.CommunicationObject.ProcessOpening () [0x00017] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:276 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:169 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:164 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ChannelFactory.EnsureOpened () [0x00058] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs:297 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:108 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ClientBase`1[TChannel].CreateChannel () [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:266 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ClientBase`1[TChannel].get_InnerChannel () [0x0000b] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:186 07-20 11:35:39.708 I/MonoDroid( 1452): at System.ServiceModel.ClientBase`1[TChannel].get_Channel () [0x00000] in
/Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:192 07-20 11:35:39.708 I/MonoDroid( 1452): at DataServiceClient.GetProjects (Int32 firmaid) [0x00001] in C:\Users\username\documents\visual studio 2015\Projects\somethingMobileApp
\somethingMobileAppAndroid\DataService.cs:10752 07-20 11:35:39.708 I/MonoDroid( 1452): at somethingMobileAppAndroid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0006d] in C:\Users\username\documents\visual studio 2015\Projects
\somethingMobileApp\somethingMobileAppAndroid\MainActivity.cs:50 07-20 11:35:39.708 D/Mono ( 1452): DllImport searching in: '__Internal' ('(null)'). 07-20 11:35:39.712 D/Mono ( 1452): Searching for 'java_interop_jnienv_new_string'. 07-20 11:35:39.712 D/Mono ( 1452): Probing 'java_interop_jnienv_new_string'. 07-20 11:35:39.712 D/Mono ( 1452): Found as 'java_interop_jnienv_new_string'. 07-20 11:35:39.716 D/Mono ( 1452): DllImport searching in: '__Internal' ('(null)'). 07-20 11:35:39.716 D/Mono ( 1452): Searching for 'java_interop_jnienv_throw'. 07-20 11:35:39.716 D/Mono ( 1452): Probing 'java_interop_jnienv_throw'. 07-20 11:35:39.716 D/Mono ( 1452): Found as 'java_interop_jnienv_throw'. An unhandled exception occured.
07-20 11:35:42.112 E/mono ( 1452): 07-20 11:35:42.112 E/mono ( 1452): Unhandled Exception: 07-20 11:35:42.112 E/mono ( 1452): System.NotImplementedException: The method or operation is not implemented. 07-20 11:35:42.112 E/mono ( 1452): at (wrapper dynamic-method) System.Object:c637c172-2e79-4a17-a720-5e2325d945f7 (intptr,intptr,intptr) 07-20 11:35:42.112 E/mono ( 1452): at (wrapper native-to-managed) System.Object:c637c172-2e79-4a17-a720-5e2325d945f7 (intptr,intptr,intptr) In mgmain JNI_OnLoad 07-20 11:35:42.112 E/mono-rt ( 1452): [ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: The method or operation is not implemented. 07-20 11:35:42.112 E/mono-rt ( 1452): at (wrapper dynamic-method) System.Object:c637c172-2e79-4a17-a720-5e2325d945f7 (intptr,intptr,intptr) 07-20 11:35:42.112 E/mono-rt ( 1452): at (wrapper native-to-managed) System.Object:c637c172-2e79-4a17-a720-5e2325d945f7 (intptr,intptr,intptr)
Any suggestion ? :)