2009-10-23 2 views
0

J'utilise Silverlight 3 Prism (CAB) avec WCFlecture de ServiceReferences.ClientConfig dans WCF dans Silverlight 3 dans un fichier .xap dynamiquement chargé

Quand j'appelle un service WCF dans un module Prism, je reçois le même erreur:

Impossible de trouver l'élément de noeud final par défaut qui référence le contrat 'IMyService' dans la section de configuration du client de modèle de service, car aucun fichier de configuration n'a été trouvé pour votre application ou aucun élément final correspondant à ce contrat. se trouve dans l'élément client "

Il s'avère que son regard dans la She le fichier .xap de ll pour un fichier ServiceReferences.ClientConfig, pas dans le fichier ServiceReferences.ClientConfig du module. J'ai ajouté mon point de terminaison et ma liaison au fichier ServiceReferences.ClientConfig existant dans mon application Silverlight Shell (il appelle ses propres services WCF).

Puis j'ai dû reconstruire l'application Shell pour générer le nouveau fichier .xap pour le dossier ClientBin de mon projet Web.

Ensuite, je changé pour la mise en place du service dans le code:

// create the binding elements 
BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement(); 
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement() 
{ MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue}; 

HttpsTransportBindingElement httpsTransport = new HttpsTransportBindingElement() 
{ MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }; 

// add the binding elements into a Custom Binding 
CustomBinding customBinding; 
if (Application.Current.Host.Source.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase)) 
{ 
    customBinding = new CustomBinding(binaryMessageEncoding, httpsTransport); 
} 
else 
{ 
    customBinding = new CustomBinding(binaryMessageEncoding, httpTransport); 
} 

// create the Endpoint URL 
EndpointAddress endpointAddress = new EndpointAddress(

"http://localhost/Test/TestModule/Test.TestModule.WCF/TestModuleService.svc"); 

// create an interface for the WCF service 
var service = new TestModuleServiceClient(customBinding, endpointAddress); 
+0

Vous posez une question? – TheEmirOfGroofunkistan

Répondre

Questions connexes