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 :

WFC Le serveur distant a retourné une erreur : NotFound


Sujet :

Windows Communication Foundation .NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Juillet 2003
    Messages
    197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Juillet 2003
    Messages : 197
    Par défaut WFC Le serveur distant a retourné une erreur : NotFound
    Ne gaspillons pas les sujets je recycle celui ci :

    Voici mon code pour mon service :

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using System.Text;
    using AS3C.DataLayer;
    using AS3C.DataLayer.Context;
     
    namespace AS3C.WCFService
    {
        // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class SouscriptionService : ISouscriptionService
        {
            public List<T_REGION> GetRegions()
            {
                AS3C.DataLayer.Context.SouscriptionEntities context = new SouscriptionEntities();
                return (from region in context.T_REGION
                        select region).ToList();
     
                //return CommercialDataLayer.GetRegions();
            }
     
            public string GetData(int value)
            {
                return string.Format("You entered: {0}", value);
            }
     
            public CompositeType GetDataUsingDataContract(CompositeType composite)
            {
                if (composite.BoolValue)
                {
                    composite.StringValue += "Suffix";
                }
                return composite;
            }
        }
    }
    Lorsque j'essaie d'utiliser la fonction GetRegions() mon application appelant le service me renvoie une exception :

    Une exception s'est produite lors de l'opération, ce qui rend le résultat non valide. Consultez InnerException pour plus de détails sur l'exception.
    J'ai beau consulter l'innerexception mais je ne comprend vraiment pas pourquoi mon appli n'arrive pas à récupérer ma liste de regions

  2. #2
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Juillet 2003
    Messages
    197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Juillet 2003
    Messages : 197
    Par défaut
    J'avance à petit pas !

    J'ai ajouté dans la partie desginer.cs de mon edmx une fonction Fullname à une des classes de la base.

    Hors il fallait un get mais aussi un set du coup maintenant je peux ajouter mon service à ma solution.

    Mais bon il me reste toujours des bugs

  3. #3
    Membre confirmé
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Juillet 2003
    Messages
    197
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Juillet 2003
    Messages : 197
    Par défaut
    Histoire de faire avancer le schmilblik !

    J'ai tout recommencé.

    J'ai supprimer mon projet WCF, j'ai enlevé toute référence à ce projet et je suis reparti d'une base propre.

    Une fois le nouveau projet de crée, la modification dans le fichier config pour passer en
    basichttpbinding
    et le fichier clientaccesspolicy.xml suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?xml version="1.0" encoding="utf-8"?>
    <access-policy>
      <cross-domain-access>
        <policy>
          <allow-from http-request-headers="*">
            <domain uri="*"/>
          </allow-from>
          <grant-to>
            <resource path="/"
                include-subpaths="true"/>
          </grant-to>
        </policy>
      </cross-domain-access>
    </access-policy>
    ajouté à la solution je peux enfin utiliser le service.

    J'ai testé le service de base via la fonction GetData.

    Mon application SilverLight communique bien avec le service.

    Les choses se gâtent à deux moments.

    Je n'arrive pas à renommer la classe Service1.svc.cs J'ai utilisé la fonction remplacé dans toutes ma solution pour être sûr que la classe, l'interface et le fichier de config soit bien modifié mais rien n'y fait ça plante.

    Ceci reste un souci mineur et même si je suis pas fan je peux encore me débrouiller en utilisant Service1.svc.cs

    Mon vrai gros problème vient de l'utilisation de mes fonctions d'accès aux données.

    Voici le contenu de l'interface :

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
     
    namespace AS3C.WCFService
    {
        // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
        [ServiceContract]
        public interface IService1
        {
     
            [OperationContract]
            List<AS3C.DataLayer.Context.T_REGION> GetRegions();
     
            [OperationContract]
            string GetData(int value);
     
            [OperationContract]
            CompositeType GetDataUsingDataContract(CompositeType composite);
     
            // TODO: Add your service operations here
        }
     
     
        // Use a data contract as illustrated in the sample below to add composite types to service operations.
        [DataContract]
        public class CompositeType
        {
            bool boolValue = true;
            string stringValue = "Hello ";
     
            [DataMember]
            public bool BoolValue
            {
                get { return boolValue; }
                set { boolValue = value; }
            }
     
            [DataMember]
            public string StringValue
            {
                get { return stringValue; }
                set { stringValue = value; }
            }
        }
    }
    Voici le contenu de la classe :

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using System.Text;
     
    namespace AS3C.WCFService
    {
        // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
        [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
        [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class Service1 : IService1
        {
     
            public List<AS3C.DataLayer.Context.T_REGION> GetRegions()
            {
                return new AS3C.DataLayer.CommercialDataLayer().GetRegions();
            }
     
            public string GetData(int value)
            {
                return string.Format("You entered: {0}", value);
            }
     
            public CompositeType GetDataUsingDataContract(CompositeType composite)
            {
                if (composite.BoolValue)
                {
                    composite.StringValue += "Suffix";
                }
                return composite;
            }
        }
    }
    Hors dès que j'essaie d'utiliser la fonction GetRegions l'application Silverlight me renvoie une exception
    Le serveur distant a retourné une erreur : NotFound.
    Impossible de savoir d'où vient mon souci, j'ai pourtant vérifier que la classe T_REGION que je souhaite utiliser contiennent tous les éléments pour être serializable (la classe est généré automatiquement par VS) :

    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
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
        [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="SouscriptionModel", Name="T_REGION")]
        [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
        [global::System.Serializable()]
        public partial class T_REGION : global::System.Data.Objects.DataClasses.EntityObject
        {
            /// <summary>
            /// Create a new T_REGION object.
            /// </summary>
            /// <param name="rEG_INT_ID">Initial value of REG_INT_ID.</param>
            /// <param name="rEG_CAR_CODE">Initial value of REG_CAR_CODE.</param>
            /// <param name="rEG_TXT_LIBELLE">Initial value of REG_TXT_LIBELLE.</param>
            public static T_REGION CreateT_REGION(int rEG_INT_ID, string rEG_CAR_CODE, string rEG_TXT_LIBELLE)
            {
                T_REGION t_REGION = new T_REGION();
                t_REGION.REG_INT_ID = rEG_INT_ID;
                t_REGION.REG_CAR_CODE = rEG_CAR_CODE;
                t_REGION.REG_TXT_LIBELLE = rEG_TXT_LIBELLE;
                return t_REGION;
            }
            /// <summary>
            /// There are no comments for Property REG_INT_ID in the schema.
            /// </summary>
            [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
            [global::System.Runtime.Serialization.DataMemberAttribute()]
            public int REG_INT_ID
            {
                get
                {
                    return this._REG_INT_ID;
                }
                set
                {
                    this.OnREG_INT_IDChanging(value);
                    this.ReportPropertyChanging("REG_INT_ID");
                    this._REG_INT_ID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                    this.ReportPropertyChanged("REG_INT_ID");
                    this.OnREG_INT_IDChanged();
                }
            }
            private int _REG_INT_ID;
            partial void OnREG_INT_IDChanging(int value);
            partial void OnREG_INT_IDChanged();
            /// <summary>
            /// There are no comments for Property REG_CAR_CODE in the schema.
            /// </summary>
            [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
            [global::System.Runtime.Serialization.DataMemberAttribute()]
            public string REG_CAR_CODE
            {
                get
                {
                    return this._REG_CAR_CODE;
                }
                set
                {
                    this.OnREG_CAR_CODEChanging(value);
                    this.ReportPropertyChanging("REG_CAR_CODE");
                    this._REG_CAR_CODE = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
                    this.ReportPropertyChanged("REG_CAR_CODE");
                    this.OnREG_CAR_CODEChanged();
                }
            }
            private string _REG_CAR_CODE;
            partial void OnREG_CAR_CODEChanging(string value);
            partial void OnREG_CAR_CODEChanged();
            /// <summary>
            /// There are no comments for Property REG_TXT_LIBELLE in the schema.
            /// </summary>
            [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
            [global::System.Runtime.Serialization.DataMemberAttribute()]
            public string REG_TXT_LIBELLE
            {
                get
                {
                    return this._REG_TXT_LIBELLE;
                }
                set
                {
                    this.OnREG_TXT_LIBELLEChanging(value);
                    this.ReportPropertyChanging("REG_TXT_LIBELLE");
                    this._REG_TXT_LIBELLE = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
                    this.ReportPropertyChanged("REG_TXT_LIBELLE");
                    this.OnREG_TXT_LIBELLEChanged();
                }
            }
            private string _REG_TXT_LIBELLE;
            partial void OnREG_TXT_LIBELLEChanging(string value);
            partial void OnREG_TXT_LIBELLEChanged();
            /// <summary>
            /// There are no comments for Property REG_TXT_SOUS_REGION in the schema.
            /// </summary>
            [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
            [global::System.Runtime.Serialization.DataMemberAttribute()]
            public string REG_TXT_SOUS_REGION
            {
                get
                {
                    return this._REG_TXT_SOUS_REGION;
                }
                set
                {
                    this.OnREG_TXT_SOUS_REGIONChanging(value);
                    this.ReportPropertyChanging("REG_TXT_SOUS_REGION");
                    this._REG_TXT_SOUS_REGION = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                    this.ReportPropertyChanged("REG_TXT_SOUS_REGION");
                    this.OnREG_TXT_SOUS_REGIONChanged();
                }
            }
            private string _REG_TXT_SOUS_REGION;
            partial void OnREG_TXT_SOUS_REGIONChanging(string value);
            partial void OnREG_TXT_SOUS_REGIONChanged();
            /// <summary>
            /// There are no comments for T_COMMERCIAL in the schema.
            /// </summary>
            [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("SouscriptionModel", "REF_REG_CAL", "T_COMMERCIAL")]
            [global::System.Xml.Serialization.XmlIgnoreAttribute()]
            [global::System.Xml.Serialization.SoapIgnoreAttribute()]
            [global::System.Runtime.Serialization.DataMemberAttribute()]
            public global::System.Data.Objects.DataClasses.EntityCollection<T_COMMERCIAL> T_COMMERCIAL
            {
                get
                {
                    return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<T_COMMERCIAL>("SouscriptionModel.REF_REG_CAL", "T_COMMERCIAL");
                }
                set
                {
                    if ((value != null))
                    {
                        ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<T_COMMERCIAL>("SouscriptionModel.REF_REG_CAL", "T_COMMERCIAL", value);
                    }
                }
            }
        }
    ma fonction :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     new AS3C.DataLayer.CommercialDataLayer().GetRegions();
    fonctionne bien je l'ai testé dans une winform. Du coup je pense avoir réunit tous les éléments pour pouvoir faire communiquer mon service avec mon application Silverlight et pourtant je rencontre toujours des gros problèmes.

    En espérant que vous puissiez me donner des éléments pour résoudre mon souci je vais repartir sur un webservice, au moins c'est plus simple à mettre en place

Discussions similaires

  1. Le serveur distant a retourné une erreur: NotFound
    Par FirePrawn dans le forum Windows Communication Foundation
    Réponses: 2
    Dernier message: 18/01/2016, 01h39
  2. Exception: le serveur distant a retourné une erreur not found
    Par sahlyhassani007 dans le forum Silverlight
    Réponses: 2
    Dernier message: 04/03/2012, 18h20
  3. Le serveur distant a retourné une erreur : NotFound
    Par Louis745 dans le forum Silverlight
    Réponses: 3
    Dernier message: 08/10/2010, 00h38
  4. Réponses: 8
    Dernier message: 05/02/2008, 11h35
  5. [MSSQL 2005] Retourner une erreure dans une SP
    Par Danny Blue dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 01/08/2006, 08h19

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