none
Problema con WcfDataService al invocar un Store Procedure RRS feed

  • Pregunta

  • Hola buen día

    tengo un Data Service:

    public class PLCDataService : DataService<LegitimacionEntities>
        {
    
            public static void InitializeService(DataServiceConfiguration config)
            {
                config.SetEntitySetAccessRule("TablasLeg", EntitySetRights.All);
                config.SetServiceOperationAccessRule("GetMatchOFAC", ServiceOperationRights.All);
                config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            }
    
            [WebGet]
            public IQueryable<TablasLeg> GetMatchOFAC(string name)
            {
                return CurrentDataSource
                    .GetMatchOFAC(name)
                    .AsQueryable();
            }
        }

    Yo lo pruebo en el browser y funciona bien...

    Luego cuando lo agrego el servicio y lo invoco en mi codigo:

    ListasIlicitas.LegitimacionEntities context = 
               new ListasIlicitas.LegitimacionEntities(new Uri(ConfigurationManager.AppSettings["uriPLCListas"]));
    gvResultados.DataSource = context.
                        

    en el context. no me aparece el metodo GetMatchOfac, alguien sabe porque podria estar pasando esto?

    Gracias de antemano y feliz día



    lunes, 30 de julio de 2012 21:33

Respuestas

  • Hola buen día

    La solución que conseguí y aplique que me funciona en el cliente es esta:

    queryString = "GetMatchOFAC?Name='" + textoBuscado + "'";
                        return context.Execute<ListasIlicitas.TablasLeg>(new Uri(queryString, UriKind.Relative)).ToList();

    El caso es que al parecer no accede directamente a los metodos de los dataservice por los cual no me aparecia en el intellisense y me daba error, y hay que agregarlo como codigo no tipado con el _contexto.CreateQuery<TablaClientes>("NombreStore").ToList(); esto funciona si no se le tienen que pasar parametros en otro caso lo pueden aplicar de la manera en que lo hice...

    de igual modo muchas gracias por su apoyo y feliz día...



    • Marcado como respuesta Lord Daemons jueves, 2 de agosto de 2012 16:43
    jueves, 2 de agosto de 2012 16:42

Todas las respuestas

  • Hola,

    ¿Has probado a actualizar la referencia de Servicio?

    Un saludo.


    Javier Torrecilla
    Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
    Si la respuesta te ha sido util Votala.
    Mi Blog: Jtorrecilla
    Enlace a Faq de Winforms en Ingles Muy bueno
    TabControl con Mejoras

    martes, 31 de julio de 2012 6:20
  • si eh usado el update service reference varias veces pero nada por ejemplo esto es lo que esta contenido en el reference.cs de la referencia del dataservice: (yo revise alli si me generaba el GetMatchOfac y no lo encontre... Por lo cual nose porque no me lo genera...)

    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:4.0.30319.269
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    
    // Original file name:
    // Generation date: 30/07/2012 04:37:25 p.m.
    namespace Balcones.ListasIlicitas
    {
        
        /// <summary>
        /// There are no comments for LegitimacionEntities in the schema.
        /// </summary>
        public partial class LegitimacionEntities : global::System.Data.Services.Client.DataServiceContext
        {
            /// <summary>
            /// Initialize a new LegitimacionEntities object.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public LegitimacionEntities(global::System.Uri serviceRoot) : 
                    base(serviceRoot)
            {
                this.ResolveName = new global::System.Func<global::System.Type, string>(this.ResolveNameFromType);
                this.ResolveType = new global::System.Func<string, global::System.Type>(this.ResolveTypeFromName);
                this.OnContextCreated();
            }
            partial void OnContextCreated();
            /// <summary>
            /// Since the namespace configured for this service reference
            /// in Visual Studio is different from the one indicated in the
            /// server schema, use type-mappers to map between the two.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            protected global::System.Type ResolveTypeFromName(string typeName)
            {
                if (typeName.StartsWith("LegitimacionModel", global::System.StringComparison.Ordinal))
                {
                    return this.GetType().Assembly.GetType(string.Concat("Balcones.ListasIlicitas", typeName.Substring(17)), false);
                }
                return null;
            }
            /// <summary>
            /// Since the namespace configured for this service reference
            /// in Visual Studio is different from the one indicated in the
            /// server schema, use type-mappers to map between the two.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            protected string ResolveNameFromType(global::System.Type clientType)
            {
                if (clientType.Namespace.Equals("Balcones.ListasIlicitas", global::System.StringComparison.Ordinal))
                {
                    return string.Concat("LegitimacionModel.", clientType.Name);
                }
                return null;
            }
            /// <summary>
            /// There are no comments for TablasLeg in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public global::System.Data.Services.Client.DataServiceQuery<TablasLeg> TablasLeg
            {
                get
                {
                    if ((this._TablasLeg == null))
                    {
                        this._TablasLeg = base.CreateQuery<TablasLeg>("TablasLeg");
                    }
                    return this._TablasLeg;
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private global::System.Data.Services.Client.DataServiceQuery<TablasLeg> _TablasLeg;
            /// <summary>
            /// There are no comments for TablasLeg in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public void AddToTablasLeg(TablasLeg tablasLeg)
            {
                base.AddObject("TablasLeg", tablasLeg);
            }
        }
        /// <summary>
        /// There are no comments for LegitimacionModel.TablasLeg in the schema.
        /// </summary>
        /// <KeyProperties>
        /// ent_num
        /// Add_num
        /// alt_num
        /// </KeyProperties>
        [global::System.Data.Services.Common.EntitySetAttribute("TablasLeg")]
        [global::System.Data.Services.Common.DataServiceKeyAttribute("ent_num", "Add_num", "alt_num")]
        public partial class TablasLeg : global::System.ComponentModel.INotifyPropertyChanged
        {
            /// <summary>
            /// Create a new TablasLeg object.
            /// </summary>
            /// <param name="ent_num">Initial value of ent_num.</param>
            /// <param name="add_num">Initial value of Add_num.</param>
            /// <param name="alt_num">Initial value of alt_num.</param>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public static TablasLeg CreateTablasLeg(int ent_num, int add_num, int alt_num)
            {
                TablasLeg tablasLeg = new TablasLeg();
                tablasLeg.ent_num = ent_num;
                tablasLeg.Add_num = add_num;
                tablasLeg.alt_num = alt_num;
                return tablasLeg;
            }
            /// <summary>
            /// There are no comments for Property ent_num in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public int ent_num
            {
                get
                {
                    return this._ent_num;
                }
                set
                {
                    this.Onent_numChanging(value);
                    this._ent_num = value;
                    this.Onent_numChanged();
                    this.OnPropertyChanged("ent_num");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private int _ent_num;
            partial void Onent_numChanging(int value);
            partial void Onent_numChanged();
            /// <summary>
            /// There are no comments for Property SDN_Name in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string SDN_Name
            {
                get
                {
                    return this._SDN_Name;
                }
                set
                {
                    this.OnSDN_NameChanging(value);
                    this._SDN_Name = value;
                    this.OnSDN_NameChanged();
                    this.OnPropertyChanged("SDN_Name");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _SDN_Name;
            partial void OnSDN_NameChanging(string value);
            partial void OnSDN_NameChanged();
            /// <summary>
            /// There are no comments for Property SDN_Type in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string SDN_Type
            {
                get
                {
                    return this._SDN_Type;
                }
                set
                {
                    this.OnSDN_TypeChanging(value);
                    this._SDN_Type = value;
                    this.OnSDN_TypeChanged();
                    this.OnPropertyChanged("SDN_Type");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _SDN_Type;
            partial void OnSDN_TypeChanging(string value);
            partial void OnSDN_TypeChanged();
            /// <summary>
            /// There are no comments for Property Program in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Program
            {
                get
                {
                    return this._Program;
                }
                set
                {
                    this.OnProgramChanging(value);
                    this._Program = value;
                    this.OnProgramChanged();
                    this.OnPropertyChanged("Program");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Program;
            partial void OnProgramChanging(string value);
            partial void OnProgramChanged();
            /// <summary>
            /// There are no comments for Property Title in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Title
            {
                get
                {
                    return this._Title;
                }
                set
                {
                    this.OnTitleChanging(value);
                    this._Title = value;
                    this.OnTitleChanged();
                    this.OnPropertyChanged("Title");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Title;
            partial void OnTitleChanging(string value);
            partial void OnTitleChanged();
            /// <summary>
            /// There are no comments for Property Call_Sign in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Call_Sign
            {
                get
                {
                    return this._Call_Sign;
                }
                set
                {
                    this.OnCall_SignChanging(value);
                    this._Call_Sign = value;
                    this.OnCall_SignChanged();
                    this.OnPropertyChanged("Call_Sign");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Call_Sign;
            partial void OnCall_SignChanging(string value);
            partial void OnCall_SignChanged();
            /// <summary>
            /// There are no comments for Property Vess_type in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Vess_type
            {
                get
                {
                    return this._Vess_type;
                }
                set
                {
                    this.OnVess_typeChanging(value);
                    this._Vess_type = value;
                    this.OnVess_typeChanged();
                    this.OnPropertyChanged("Vess_type");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Vess_type;
            partial void OnVess_typeChanging(string value);
            partial void OnVess_typeChanged();
            /// <summary>
            /// There are no comments for Property Tonnage in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Tonnage
            {
                get
                {
                    return this._Tonnage;
                }
                set
                {
                    this.OnTonnageChanging(value);
                    this._Tonnage = value;
                    this.OnTonnageChanged();
                    this.OnPropertyChanged("Tonnage");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Tonnage;
            partial void OnTonnageChanging(string value);
            partial void OnTonnageChanged();
            /// <summary>
            /// There are no comments for Property GRT in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string GRT
            {
                get
                {
                    return this._GRT;
                }
                set
                {
                    this.OnGRTChanging(value);
                    this._GRT = value;
                    this.OnGRTChanged();
                    this.OnPropertyChanged("GRT");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _GRT;
            partial void OnGRTChanging(string value);
            partial void OnGRTChanged();
            /// <summary>
            /// There are no comments for Property Vess_flag in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Vess_flag
            {
                get
                {
                    return this._Vess_flag;
                }
                set
                {
                    this.OnVess_flagChanging(value);
                    this._Vess_flag = value;
                    this.OnVess_flagChanged();
                    this.OnPropertyChanged("Vess_flag");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Vess_flag;
            partial void OnVess_flagChanging(string value);
            partial void OnVess_flagChanged();
            /// <summary>
            /// There are no comments for Property Vess_owner in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Vess_owner
            {
                get
                {
                    return this._Vess_owner;
                }
                set
                {
                    this.OnVess_ownerChanging(value);
                    this._Vess_owner = value;
                    this.OnVess_ownerChanged();
                    this.OnPropertyChanged("Vess_owner");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Vess_owner;
            partial void OnVess_ownerChanging(string value);
            partial void OnVess_ownerChanged();
            /// <summary>
            /// There are no comments for Property Remarks in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Remarks
            {
                get
                {
                    return this._Remarks;
                }
                set
                {
                    this.OnRemarksChanging(value);
                    this._Remarks = value;
                    this.OnRemarksChanged();
                    this.OnPropertyChanged("Remarks");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Remarks;
            partial void OnRemarksChanging(string value);
            partial void OnRemarksChanged();
            /// <summary>
            /// There are no comments for Property Add_num in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public int Add_num
            {
                get
                {
                    return this._Add_num;
                }
                set
                {
                    this.OnAdd_numChanging(value);
                    this._Add_num = value;
                    this.OnAdd_numChanged();
                    this.OnPropertyChanged("Add_num");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private int _Add_num;
            partial void OnAdd_numChanging(int value);
            partial void OnAdd_numChanged();
            /// <summary>
            /// There are no comments for Property Address in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Address
            {
                get
                {
                    return this._Address;
                }
                set
                {
                    this.OnAddressChanging(value);
                    this._Address = value;
                    this.OnAddressChanged();
                    this.OnPropertyChanged("Address");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Address;
            partial void OnAddressChanging(string value);
            partial void OnAddressChanged();
            /// <summary>
            /// There are no comments for Property City in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string City
            {
                get
                {
                    return this._City;
                }
                set
                {
                    this.OnCityChanging(value);
                    this._City = value;
                    this.OnCityChanged();
                    this.OnPropertyChanged("City");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _City;
            partial void OnCityChanging(string value);
            partial void OnCityChanged();
            /// <summary>
            /// There are no comments for Property Country in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Country
            {
                get
                {
                    return this._Country;
                }
                set
                {
                    this.OnCountryChanging(value);
                    this._Country = value;
                    this.OnCountryChanged();
                    this.OnPropertyChanged("Country");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Country;
            partial void OnCountryChanging(string value);
            partial void OnCountryChanged();
            /// <summary>
            /// There are no comments for Property Add_remarks in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string Add_remarks
            {
                get
                {
                    return this._Add_remarks;
                }
                set
                {
                    this.OnAdd_remarksChanging(value);
                    this._Add_remarks = value;
                    this.OnAdd_remarksChanged();
                    this.OnPropertyChanged("Add_remarks");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _Add_remarks;
            partial void OnAdd_remarksChanging(string value);
            partial void OnAdd_remarksChanged();
            /// <summary>
            /// There are no comments for Property alt_num in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public int alt_num
            {
                get
                {
                    return this._alt_num;
                }
                set
                {
                    this.Onalt_numChanging(value);
                    this._alt_num = value;
                    this.Onalt_numChanged();
                    this.OnPropertyChanged("alt_num");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private int _alt_num;
            partial void Onalt_numChanging(int value);
            partial void Onalt_numChanged();
            /// <summary>
            /// There are no comments for Property alt_type in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string alt_type
            {
                get
                {
                    return this._alt_type;
                }
                set
                {
                    this.Onalt_typeChanging(value);
                    this._alt_type = value;
                    this.Onalt_typeChanged();
                    this.OnPropertyChanged("alt_type");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _alt_type;
            partial void Onalt_typeChanging(string value);
            partial void Onalt_typeChanged();
            /// <summary>
            /// There are no comments for Property alt_name in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string alt_name
            {
                get
                {
                    return this._alt_name;
                }
                set
                {
                    this.Onalt_nameChanging(value);
                    this._alt_name = value;
                    this.Onalt_nameChanged();
                    this.OnPropertyChanged("alt_name");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _alt_name;
            partial void Onalt_nameChanging(string value);
            partial void Onalt_nameChanged();
            /// <summary>
            /// There are no comments for Property alt_remarks in the schema.
            /// </summary>
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public string alt_remarks
            {
                get
                {
                    return this._alt_remarks;
                }
                set
                {
                    this.Onalt_remarksChanging(value);
                    this._alt_remarks = value;
                    this.Onalt_remarksChanged();
                    this.OnPropertyChanged("alt_remarks");
                }
            }
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            private string _alt_remarks;
            partial void Onalt_remarksChanging(string value);
            partial void Onalt_remarksChanged();
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
            [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
            protected virtual void OnPropertyChanged(string property)
            {
                if ((this.PropertyChanged != null))
                {
                    this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property));
                }
            }
        }
    }



    martes, 31 de julio de 2012 12:29
  • Imagino que los servicios los tienes en otro proyecto de tu solución:

    1) Has agregado el contrato en la Interfaz del Servicio, antes de definir el código?

    2) Regenerá la solución contenedora de los servicios.

    3) Después de regenerar, revisa que la referencia al EndPoint dentro del fichero de configuración de la aplicación hace referencia a la url correcta.

    4) Actualiza la referencia de servicio.

    En principio con estos pasos todo deberia funcionarte Ok.


    Javier Torrecilla
    Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
    Si la respuesta te ha sido util Votala.
    Mi Blog: Jtorrecilla
    Enlace a Faq de Winforms en Ingles Muy bueno
    TabControl con Mejoras

    miércoles, 1 de agosto de 2012 13:22
  • Hola buen día

    La solución que conseguí y aplique que me funciona en el cliente es esta:

    queryString = "GetMatchOFAC?Name='" + textoBuscado + "'";
                        return context.Execute<ListasIlicitas.TablasLeg>(new Uri(queryString, UriKind.Relative)).ToList();

    El caso es que al parecer no accede directamente a los metodos de los dataservice por los cual no me aparecia en el intellisense y me daba error, y hay que agregarlo como codigo no tipado con el _contexto.CreateQuery<TablaClientes>("NombreStore").ToList(); esto funciona si no se le tienen que pasar parametros en otro caso lo pueden aplicar de la manera en que lo hice...

    de igual modo muchas gracias por su apoyo y feliz día...



    • Marcado como respuesta Lord Daemons jueves, 2 de agosto de 2012 16:43
    jueves, 2 de agosto de 2012 16:42