Quel est l'état de Mono pour les services WCF sécurisés d'Android? Est-ce que c'est encore SOAP 1.2? Je suis en train d'écrire un POC pour une application Android qui va interagir avec les services de la WCF, mais j'ai du mal à faire fonctionner la chose. J'essaie de me connecter à un service qui a la sécurité TransportWithMessageCredential
. Cependant, je reçois une erreur du côté du serveur.MessageSecurityException: Le processeur de sécurité n'a pas trouvé d'en-tête de sécurité dans le message
C'est l'erreur côté serveur:
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.
serveur 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>
Code client:
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;
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
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;
}
private bool OnServerCertificateValidationCallback(object sender, X509Certificate certificate,
X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
}
Ce code fonctionne très bien dans WPF, le résultat est renvoyé et Tout est bien. Je vois d'anciens threads que la WCF est encore au début du cycle de développement, mais je veux juste vérifier si peut-être que je fais quelque chose de mal en premier.
Notez que enableUnsecuredResponse ne fonctionne pas avec basicHttpBinding. Cela fonctionne sur customBinding, cependant. – thomasb