Matt,
I'd like to hear about your progress, issues that you run into, and anything 
that you feel would be good to share.  
Wally

Date: Wed, 9 May 2012 17:15:43 +0200
From: [email protected]
To: [email protected]
Subject: Re: [mono-android] Mono for Android's secure WCF services

I have been implementing a REST endpoint now and it seems to be quite smooth 
going. I think this is what I'll be doing.
I thought it was going to be harder, but it is pretty clean and neat.


On Wed, May 9, 2012 at 3:27 PM, Wally McClure <[email protected]> 
wrote:





One of the things I am liking about REST is a the ability to get away from the 
proxy.  There are a lot of reasons why a proxy is a good thing in development, 
however, the proxy is a hassle in the iPhone/MonoTouch world.  If I could get a 
REST proxy in the dev world that somehow turned itself off when it was deployed 
to an emulator/simulator or device, that would be awesome, but i don't see that 
happening any time soon.

 
Wally
 
Date: Wed, 9 May 2012 14:17:24 +0100
From: [email protected]
To: [email protected]

Subject: Re: [mono-android] Mono for Android's secure WCF services

I second that. I've been using WCF REST services, with JSON formatting and 
https endpoints, and so far, the overall experience is great.


On 9 May 2012 14:11, Wally McClure <[email protected]> wrote:





Matt,
 
If you are using WCF and having problems, what about setting the services to be 
REST based?  After experimentation, I am going to REST, JSON, and, if you need 
security what about https?  Or, have I missed something somewhere on a list 
about this being bad?  


 
Wally
 
PS. I read about JSON support for .NET 4 via NuGet, but have no experience with 
it.
Date: Wed, 9 May 2012 09:14:04 +0200
From: [email protected]


To: [email protected]
Subject: [mono-android] Mono for Android's secure WCF services

Hi All,

What is the state of Mono for Android's secure WCF services? Is it up to SOAP 
1.2 yet? 


I am writing a Proof of Concept for an Android app that will interact with WCF 
services, but am struggling to get the thing working. It will be an enterprise 
app that will use WiFi and needs to be secure as it will be carrying the 
companies confidential data.





I did see you FAQ, but want to know for sure the current status: 
http://support.xamarin.com/customer/portal/articles/142151-does-mono-for-android-support-wcf-
 and this thread seems bad things about it: 
http://mono-for-android.1047100.n5.nabble.com/Calling-arbitrary-web-services-td4959774.html





I am trying to connect to a service that has `TransportWithMessageCredential` 
security. However I am getting an error on the server side:



MessageSecurityException: 
Security processor was unable to find a security header in the message. 
This might be because the message is an unsecured fault or because there is a 
binding mismatch between the communicating parties. 




This can occur if the service is configured for security and the client is not 
using security.

Server Config:

    <service 
name="BrandDirector.ApplicationServer.Core.Services.UI.Products.Specifications.IngredientService"
 



             behaviorConfiguration="CredentialValidation">        <endpoint 
address="/BasicHttp"



            binding="basicHttpBinding"            
bindingConfiguration="BDBasicHttpBindingWithSecurity" 



            
contract="BrandDirector.ApplicationServer.Core.Services.UI.Products.Specifications.IIngredientService"
 />



        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" 
address="mex" />



    </service>    <behavior name="CredentialValidation">



      <serviceMetadata httpGetEnabled="true" />      <serviceDebug 
includeExceptionDetailInFaults="true" />



      <HttpStatusCode200Behavior />      <serviceCredentials 
type="BrandDirector.ApplicationServer.Core.Security.Authentication.PasswordServiceCredentials,
 BrandDirector.ApplicationServer.Core.Security, Version=1.0.0.0, 
Culture=neutral">



        <userNameAuthentication userNamePasswordValidationMode="Custom"         
 
customUserNamePasswordValidatorType="BrandDirector.ApplicationServer.Core.Security.CredentialValidator,
 BrandDirector.ApplicationServer.Core.Security" />



      </serviceCredentials>    </behavior>



    <extensions>      <behaviorExtensions>



        <add name="HttpStatusCode200Behavior" 
type="BrandDirector.ApplicationServer.Core.Services.Common.ServiceModel.HttpStatusCode200BehaviorExtension,
 BrandDirector.ApplicationServer.Core.Services.Common" />



      </behaviorExtensions>      <basicHttpBinding>



        <binding name="BDBasicHttpBindingWithSecurity" messageEncoding="Text" 
maxReceivedMessageSize="655536">



          <security mode="TransportWithMessageCredential" >            <message 
clientCredentialType="UserName" />



          </security>        </binding>



      </basicHttpBinding>    </extensions>






Client Code:

    public class Activity1 : Activity    {



        private Button button;        const string address = 
"https://.../IngredientService.svc/BasicHttp";;



        protected override void OnCreate(Bundle bundle)        {



            base.OnCreate(bundle);



            var timeout = new TimeSpan(0, 1, 0);            var binding = new 
BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential)



            {                MessageEncoding = WSMessageEncoding.Text,



                Security =                {



                    Transport =                    {



                        ClientCredentialType = HttpClientCredentialType.None,   
                     ProxyCredentialType = HttpProxyCredentialType.None



                    },                    Message =



                    {                        ClientCredentialType = 
BasicHttpMessageCredentialType.UserName,



                    }                },



                HostNameComparisonMode = HostNameComparisonMode.StrongWildcard, 
               MaxReceivedMessageSize = 655536,



                ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas         
       {



                    MaxArrayLength = 655536,                    
MaxStringContentLength = 655536,



                },                SendTimeout = timeout,



                OpenTimeout = timeout,                ReceiveTimeout = timeout,



            };            
System.Net.ServicePointManager.ServerCertificateValidationCallback += 
OnServerCertificateValidationCallback;



            SetContentView(Resource.Layout.Main);



            button = FindViewById<Button>(Resource.Id.MyButton);



            button.Click += delegate            {



                client = new IngredientServiceClient(binding, new 
EndpointAddress(address));                var clientCredential = 
client.ClientCredentials.UserName;



                clientCredential.UserName = "admin";                
clientCredential.Password = "KDNSG7";



                client.BeginGetIngredients("e", callBack, null);



            };        }



        IngredientServiceClient client;        



        private void callBack(IAsyncResult ar)        {



            var result = client.EndGetIngredients(ar);            



            button.Text = result.First().Name;        }



                                // Ignore and certificate errors
        private bool OnServerCertificateValidationCallback(object sender, 
X509Certificate certificate, 



                                                           X509Chain chain, 
SslPolicyErrors sslPolicyErrors)        {



            return true;        }



    }

This code works fine in WPF, the result is returned and all is well. I do see 
from older threads and the FAQ that the WCF is still early in the development 
cycle, but I just want to check if maybe I am doing something wrong first.





In Anticipation,
Matthew




_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid                              
          

_______________________________________________

Monodroid mailing list

[email protected]



UNSUBSCRIBE INFORMATION:

http://lists.ximian.com/mailman/listinfo/monodroid




-- 
Gonçalo Oliveira



_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid                              
          

_______________________________________________

Monodroid mailing list

[email protected]



UNSUBSCRIBE INFORMATION:

http://lists.ximian.com/mailman/listinfo/monodroid





_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid                              
          
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to