Bonjour à tous,
Je voulais me lancer dans un projet d'application Silverlight 5 communiquant avec web service WCF en PollingDuplex mais je me heurte à une erreur. J'ai fait la démonstration présente sur le msdn (http://msdn.microsoft.com/fr-fr/libr...=vs.95%29.aspx) qui marche très bien et j'ai tenté de l'adapter à un projet personnel.
Il en résulte l'erreur suivante.
Dans mon ServiceReference.cs (généré automatiquement
1 2 3 4
| public void EndConnect(System.IAsyncResult result) {
object[] _args = new object[0];
base.EndInvoke("Connect", _args, result);
} |
Le base.EndInvoke génère l'erreur suivante :
Une erreur s'est produite en tentant d'effectuer une demande à l'URI 'http://localhost:24942/ZombieDiceWS.svc'. Ce problème peut être dû à une tentative d'accès à un service entre domaines sans qu'une stratégie entre domaines appropriée soit en place, ou une stratégie inadaptée aux services SOAP. Il est possible que vous soyez contraint de contacter le propriétaire du service pour publier un fichier de stratégie entre domaines et veiller à ce qu'il autorise l'envoi d'en-têtes HTTP SOAP. Cette erreur peut également être liée à l'utilisation de types internes dans le proxy de service Web sans utiliser l'attribut InternalsVisibleToAttribute. Consultez l'exception interne pour plus de détails.
Inner Exception que voilà:
1 2 3 4
| {System.Security.SecurityException: Erreur de sécurité.
à System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
à System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)
à System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)} |
Mon web.config ressemble à ça pour la partie service :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <system.serviceModel>
<!--Extension rajoutée pour supporter le pollingDuplex-->
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<!--Définition des bindings-->
<bindings>
<pollingDuplexHttpBinding>
<binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
duplexMode="MultipleMessagesPerPoll"
maxOutputDelay="00:00:07"/>
</pollingDuplexHttpBinding>
</bindings>
<!--Définition des services-->
<services>
<service name="ZombieDiceWS.ZombieDiceWS">
<!-- Service Endpoints -->
<endpoint
address=""
binding="pollingDuplexHttpBinding"
bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="ZombieDiceWS.IZombieDiceWS">
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<!--Configuration de base, laissée car plante sans-->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<!--Définition des comportements-->
<behaviors>
<serviceBehaviors>
<behavior>
<!--To avoid disclosing metadata information, set the value below to false before deployment-->
<serviceMetadata httpGetEnabled="true"/>
<!--To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information-->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel> |
J'instancie mon webservice côté client de cette façon :
1 2 3 4 5 6
| EndpointAddress address = new EndpointAddress("http://localhost:24942/ZombieDiceWS.svc");
PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll);
ZombieDiceWSClient ZDService = new ZombieDiceWSClient(binding, address);
ZDService.DisplayMessageReceived += ZDService_DisplayMessageReceived;
ZDService.ConnectAsync("test", "test"); |
Et la fonction connect côté web service ressemble à ceci:
1 2 3 4 5 6
| public void Connect(string login, string password)
{
client = OperationContext.Current.GetCallbackChannel<IZombieDiceServiceCallback>();
//rappel("Vous êtes connecté");
//return Guid.NewGuid().ToString();
} |
Rien de réellement transcendant donc. Je pensais avoir scrupuleusement suivi les indication de l'exemple msdn, mais forcé de constater que je me suis trompé quelque part.
Quelqu'un aurait-il une idée pour me sauver de cette galère ?
Merci infiniment d'avance !
Partager