IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Communication Foundation .NET Discussion :

WCF RIA Services - Pb création service de domaine


Sujet :

Windows Communication Foundation .NET

  1. #1
    Membre habitué Avatar de mumu27
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2009
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Eure (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 213
    Points : 128
    Points
    128
    Par défaut WCF RIA Services - Pb création service de domaine
    Bonjour,

    j'ai un souci dans la mise en place d'un WCF RIA Services. Le client est une application Silverlight "LearningCompany_RIA". Le service que je conçois doit être hébergé par une application ASP.NET "LearningCompany". C'est pourquoi dans les propriétés du projet Silverlight "LearningCompany_RIA", nous spécifions le projet ASP.NET comme lien WCF RIA Services.

    Je crée ensuite un service de domaine dans le projet web LearningCompany "FormateursDomainService.cs".

    Comme j'ai un projet LearningCompany_DAO qui est une bibliothèque de classes qui utilise le Framework entity, je choisis pour ma modélisation Objet/Relationnel le contexte de données liés LearningCompanyEntities. j'ai décidé d'exposer les données Formateur et SessionFormation en Crud et Civilite en lecture.

    Pour rendre accessible le service, j'ajoute au fichier Web.config:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    <location path="Services">
        <system.web>
          <authorization>
            <allow users="?"/>
          </authorization>
        </system.web>
      </location>
    Lorsque je compile la solution, voici le message d'erreur qui apparaît:
    Error 2 Partial declarations of 'LearningCompany_DAO.Civilite' must not specify different base classes
    Error 3 Partial declarations of 'LearningCompany_DAO.Formateur' must not specify different base classe
    ...

    Tout ceci dans le fichier généré:

    C:\Users\Sébastien\Documents\Visual Studio 2010\Projects\LearningCompany\LearningCompany_RIA\Generated_Code\LearningCompany.g.cs

    J'ai mis en pièces jointes le fichier généré.

    Merci d'avance pour votre réponse.

    Mumu27!
    Fichiers attachés Fichiers attachés

  2. #2
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    Tes objets sont des objets entity Framework ? Plus utilisé RIA depuis longtemps, mais si je me rappelle bien, tes classes ne peuvent pas hériter de entity.
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  3. #3
    Membre habitué Avatar de mumu27
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2009
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Eure (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 213
    Points : 128
    Points
    128
    Par défaut
    Bonjour,

    en fait seul la partie LearningCompany_DAO est concerné par le Framework entity. Ci-joint l'arborescence de mon projet. Aussi mon service est hébergé par l'application web LearningCompany. Voici le fichier qui possède les méthodes développées par le service sous le répertoire Services de l'application Web (LearningCompany): FormateursDomainService.cs

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
     
    namespace LearningCompany.Services
    {
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Data;
        using System.Linq;
        using System.ServiceModel.DomainServices.EntityFramework;
        using System.ServiceModel.DomainServices.Hosting;
        using System.ServiceModel.DomainServices.Server;
        using LearningCompany_DAO;
     
     
        // Implements application logic using the LearningCompanyEntities context.
        // TODO: Add your application logic to these methods or in additional methods.
        // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
        // Also consider adding roles to restrict access as appropriate.
        // [RequiresAuthentication]
        [EnableClientAccess()]
        public class FormateursDomainService : LinqToEntitiesDomainService<LearningCompanyEntities>
        {
     
            // TODO:
            // Consider constraining the results of your query method.  If you need additional input you can
            // add parameters to this method or create additional query methods with different names.
            // To support paging you will need to add ordering to the 'Civilite' query.
            [Query(IsDefault = true)]
            public IQueryable<Civilite> GetCivilite()
            {
                return this.ObjectContext.Civilite;
            }
     
            // TODO:
            // Consider constraining the results of your query method.  If you need additional input you can
            // add parameters to this method or create additional query methods with different names.
            // To support paging you will need to add ordering to the 'Formateur' query.
            [Query(IsDefault = true)]
            public IQueryable<Formateur> GetFormateur()
            {
                return this.ObjectContext.Formateur.OrderByDescending(p => p.Identifiant);
            }
     
            public void InsertFormateur(Formateur formateur)
            {
                if ((formateur.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(formateur, EntityState.Added);
                }
                else
                {
                    this.ObjectContext.Formateur.AddObject(formateur);
                }
            }
     
            public void UpdateFormateur(Formateur currentFormateur)
            {
                this.ObjectContext.Formateur.AttachAsModified(currentFormateur, this.ChangeSet.GetOriginal(currentFormateur));
            }
     
            public void DeleteFormateur(Formateur formateur)
            {
                if ((formateur.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(formateur, EntityState.Deleted);
                }
                else
                {
                    this.ObjectContext.Formateur.Attach(formateur);
                    this.ObjectContext.Formateur.DeleteObject(formateur);
                }
            }
     
            // TODO:
            // Consider constraining the results of your query method.  If you need additional input you can
            // add parameters to this method or create additional query methods with different names.
            // To support paging you will need to add ordering to the 'SessionFormation' query.
            [Query(IsDefault = true)]
            public IQueryable<SessionFormation> GetSessionFormation()
            {
                return this.ObjectContext.SessionFormation;
            }
     
            public void InsertSessionFormation(SessionFormation sessionFormation)
            {
                if ((sessionFormation.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(sessionFormation, EntityState.Added);
                }
                else
                {
                    this.ObjectContext.SessionFormation.AddObject(sessionFormation);
                }
            }
     
            public void UpdateSessionFormation(SessionFormation currentSessionFormation)
            {
                this.ObjectContext.SessionFormation.AttachAsModified(currentSessionFormation, this.ChangeSet.GetOriginal(currentSessionFormation));
            }
     
            public void DeleteSessionFormation(SessionFormation sessionFormation)
            {
                if ((sessionFormation.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(sessionFormation, EntityState.Deleted);
                }
                else
                {
                    this.ObjectContext.SessionFormation.Attach(sessionFormation);
                    this.ObjectContext.SessionFormation.DeleteObject(sessionFormation);
                }
            }
        }
    }
    Normalement après cette opération et l'ajout de la directive pour le dossier Services dans fichier web.config (voir message précédent), le service devrait être accessible sous http://localhost:13825/Services/Lear...ainService.svc.

    Merci d'avance pour votre réponse, si vous avez des pistes.

    Mumu27
    Images attachées Images attachées  

  4. #4
    Membre habitué Avatar de mumu27
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2009
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Eure (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 213
    Points : 128
    Points
    128
    Par défaut
    Mes classes Civilite, SessionFormation et Formateur sont des entités du Framework entity, donc en effet elles héritent bien de la classe Entity. Mais pour moi, il ne devrait pas y avoir de souci.

  5. #5
    Membre habitué Avatar de mumu27
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2009
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Eure (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 213
    Points : 128
    Points
    128
    Par défaut
    Bonjour,

    après recherche, j'ai vu que le problème venait du service WCF que j'avais mis en place auparavant. En effet le proxy que j'utilisais pour ce service (GestionSecteursService.cs) faisait interférence avec le fichier généré. Maintenant j'ai un autre problème, dans mon projet j'ai un service WCF et un WCF Data Service (voir l'arborescence) qui je pense pose problème pour la mise en place du WCF RIA Service. Lorsque j' exécute mon projet Silverlight LearningCompany_RIA, voilà ce que j'ai comme message d'erreur:

    Unable to determine the URL to the Xap file from web LearningCompany
    Autrement à la compilation tout est OK maintenant. Avez-vous une idée de ce qui pourrait poser problème?

    Merci d'avance pour votre réponse.

    Mumu27

  6. #6
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    Visiblement ce serait un problème du csproj :
    http://stackoverflow.com/questions/6...-xap-file-from
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  7. #7
    Membre habitué Avatar de mumu27
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2009
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Eure (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 213
    Points : 128
    Points
    128
    Par défaut
    Bonjour,

    j'ai toujours un souci avec mon WCF RIA Services, car je devrais voir apparaître ma liste de formateurs(lié à la base de données) sur mon écran, hors il n'en est rien. J'ai bien l'impression que le problème vient du fait que je n'ai pas de référence de service pour mon WCF RIA Services dans mon projet Silverlight, mais cette référence dans l'exemple que j'essaye de mettre en place n'est apparemment pas utilisé. J'en ai quand même rajouté une, mais j'aurais voulu savoir ensuite comment procéder. Je transmet ci joint les fichiers qui sont nécessaires à l'affichage de la liste de formateurs.

    GererFormateurs.xaml:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <navigation:Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:EventHandlers="clr-namespace:LearningCompany_RIA.Tools"
               xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
               xmlns:ec="http://schemas.microsoft.com/expression/2010/controls" x:Class="LearningCompany_RIA.Views.GererFormateurs"
               mc:Ignorable="d"
               d:DesignWidth="640" d:DesignHeight="480"
               Title="GererFormateurs Page"  DataContext="{Binding GererFormateursViewModel, Source={StaticResource Locator}}" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">
        <Grid x:Name="LayoutRoot">
            <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">
                <StackPanel>
                    <Button Content="Ajouter un formateur" Command="{Binding AjouterFormateurCommand}"/>
                    <TextBox TextWrapping="Wrap" x:Name="txt_filtre"/>
                    <Button Content="Charger" Width="75" Command="{Binding LoadCommand}" CommandParameter="{Binding ElementName=txt_filtre, Path=Text}"/>
                    <Grid Height="239" Width="672">
                        <ListBox Visibility="Collapsed" DisplayMemberPath="Nom" ItemsSource="{Binding Formateurs}" SelectedItem="{Binding SelectedFormateur, Mode=TwoWay}" d:LayoutOverrides="Width"/>
                        <Path x:Name="path" Data="M86,46 C86,46 352,227 615,41" Margin="85.5,40.5,56.5,113.517" StrokeStartLineCap="Flat" Stretch="Fill" StrokeEndLineCap="Flat" StrokeThickness="1" StrokeMiterLimit="10" StrokeLineJoin="Miter" UseLayoutRounding="False"/>
                        <ec:PathListBox SelectedItem="{Binding SelectedFormateur, Mode=TwoWay}" DisplayMemberPath="Nom" ItemsSource="{Binding Formateurs}" HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100">
                            <ec:PathListBox.LayoutPaths>
                                <ec:LayoutPath SourceElement="{Binding ElementName=path}" Orientation="OrientToPath"/>
                            </ec:PathListBox.LayoutPaths>
                        </ec:PathListBox>
                    </Grid>
                    <Button Content="Précédent" Width="75" Command="{Binding PreviousNextCommand}" CommandParameter="-1"/>
                    <Button Content="Suivant" Width="75" Command="{Binding PreviousNextCommand}" CommandParameter="1"/>
                    <Button Content="Supprimer" Width="75" Command="{Binding DeleteCommand}" />
                    <toolkit:DataForm Name="dataForm1" EventHandlers:EditEndedBehavior.EditEnded="{Binding EditEndedCommand}" CommandButtonsVisibility="All" AutoEdit="True" CurrentItem="{Binding SelectedFormateur, Mode=TwoWay}" />
                </StackPanel>
     
            </ScrollViewer>
     
        </Grid>
    </navigation:Page>
    GererFormateurs.xaml.cs:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Windows.Navigation;
     
    namespace LearningCompany_RIA.Views
    {
        public partial class GererFormateurs : Page
        {
            public GererFormateurs()
            {
                InitializeComponent();
            }
     
            // Executes when the user navigates to this page.
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            }
     
        }
    }
    Si vous aviez une idée comment je peux procéder ensuite. J'ai ajouté une référence de service à mon client Silverlight avec Visual Studio à l'aide l'URL :"http://localhost:2889/Services/LearningCompany-Services-FormateursDomainService.svc/OData" qui s'appelle WcfRiaServiceReference.

    Merci d'avance.

    Mumu27!

  8. #8
    Membre habitué Avatar de mumu27
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2009
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Eure (Haute Normandie)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 213
    Points : 128
    Points
    128
    Par défaut
    Bonjour,

    j'ai pu résoudre mon premier problème (URL ... xap File...) en désactivant dans la page propriétés de mon application (Permettre l'exécution de l'application hors navigateur). Cependant depuis je n'arrive pas lorsque je démarre l'application à partir du projet Web LearningCompany de voir les modifications de mon fichier GererFormateurs.xaml, hors j'y ai ajouté des éléments. Je sais que lorsque j'ai cliqué sur Paramètres hors navigateur des nouveaux fichiers sont apparus(AppManifest.xml, AssemblyInfo.cs, OutOfBrowserSettings.xml) dans le répertoire Properties que j'ai laissé depuis. Peut-être ce la pose-t'il problème? Je sais que mon application reste comme figé à une certaine étape et j'essaye de comprendre pourquoi. Merci d'avance si vous avez une idée?

    Mumu27!

Discussions similaires

  1. Réponses: 27
    Dernier message: 11/08/2011, 22h12
  2. WCF RIA Services
    Par Kais. dans le forum Silverlight
    Réponses: 3
    Dernier message: 26/04/2010, 21h40
  3. Réponses: 6
    Dernier message: 22/12/2009, 21h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo