Showing posts with label WCF Web Service. Show all posts
Showing posts with label WCF Web Service. Show all posts

Wednesday, August 7, 2013

Third party WCF Web Service files (if your dev machine doesn't have access to the url of the web service) - getting WSDL - SVCUtil.exe

Run SVCUtil.exe from Visual Studio command prompt, with the url of the third party web service from a computer where you have access to the third party web service.


It will generate a .CS and .CONFIG file. The .CS file has all the method, parameter and return value information. The .CONFIG file has all the end point details.

Add the .CS file to the client project and add the details from the .CONFIG to the client config file.

Now you can access the third party web service (if your dev machine doesn't have access to the url of the web service). This is just a tip.

Creating Custom Properties for/extending the Entity framework generated class

How to create a custom property for an entity framework generated class. I had a requirement and the way I did was to create a partial class for the entity generated class. After creating the partial class, I added a property and was able to access the property in the same project.

BUT here comes problem.... This entity generated class was in a web service. After I deployed my web service and tried to test with a client application, I was not able to access the newly added custom property.


public partial class ClassA                       //original class, entity generated
    {
        public string Name { get; set; }
      
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String FROM_USER
        {
            get
            {
                return _FROM_USER;
            }
            set
            {
                OnFROM_USERChanging(value);
                ReportPropertyChanging("FROM_USER");
                _FROM_USER = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("FROM_USER");
                OnFROM_USERChanged();
            }
        }
        private global::System.String _FROM_USER;
        partial void OnFROM_USERChanging(global::System.String value);
        partial void OnFROM_USERChanged();
    }

public partial class ClassA                      //newly created partial class for the above class
    {
        public int ID { get; set; }
    }

 The above partial class didn't work for me. So I had to add an extra attribute for the new property as below:

public partial class ClassA
    {
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public int ID { get; set; }
    }

 This solution worked for me. Hope this tip helps you.