none
DataContract in WCF Service not getting Generated in XSD RRS feed

  • Question

  • I've built a million web services over the years, but I'm having a problem over the last several days that I just can't figure out?!  I've got a WCF web service with several DataContracts.  I build the service and copy the dll out to my web server.  I've got a website in Visual Studio that consumes these web services - so I go to update that service definition in VS and it is NOT picking up the new DataContract?!  It sees the other 4 DataContracts, but not this new 5th one?!  I've even tried running the following command to try and create the xsd manually - and even this command will not create any metadata for the new DataContract??

    C:\Program Files (x86)\Microsoft Visual Studio 11.0>svcutil.exe /target:metadata
     "c:\tfs\acfecom\acfe.netforum.servicelibrary\bin\debug\acfe.netforum.servicelib
    rary.dll" /directory:c:\temp\wsdl

    I'm incredibly frustrated and loosing lots of time on this.  Any help would be appreciated!


    Jeff Miller ACFE - IT Architect

    Wednesday, September 18, 2013 4:48 PM

Answers

  • I'm going to assume that you will have created this data contract by decorating an existing class in your code.  Is this class declared as public?  Is it being either consumed or returned by any of the web methods in the service?
    • Marked as answer by jeffmilleracfe Wednesday, September 18, 2013 6:34 PM
    Wednesday, September 18, 2013 5:39 PM

All replies

  • I'm going to assume that you will have created this data contract by decorating an existing class in your code.  Is this class declared as public?  Is it being either consumed or returned by any of the web methods in the service?
    • Marked as answer by jeffmilleracfe Wednesday, September 18, 2013 6:34 PM
    Wednesday, September 18, 2013 5:39 PM
  • Yeah.  Below are the classes in my WCF service.  CustomerPhoneData shows up in the xsd, but CustomerEmailData doesn't (or any new DataContract I try to put in there).

    [DataContract]
        public class CustomerPhoneData
        {
            [DataMember]
            public string faxOrPhone { get; set; }
    
            [DataMember]
            public string cst_key { get; set; }
    
            [DataMember]
            public string phoneKey { get; set; }
    
            [DataMember]
            public string phoneType { get; set; }
    
            [DataMember]
            public string phoneDisplayNumber { get; set; }
    
            [DataMember]
            public bool isPrimary { get; set; }
    
            [DataMember]
            public bool isUnlisted { get; set; }
    
            [DataMember]
            public string cph_key { get; set; }
    
            [DataMember]
            public string countryCode { get; set; }
    
            [DataMember]
            public string cty_key { get; set; }
    
            [DataMember]
            public string xWebUsername { get; set; }
    
            [DataMember]
            public string xWebPassword { get; set; }
        }
    
        [DataContract]
        public class CustomerEmailData
        {
            [DataMember]
            public string cst_key { get; set; }
    
            [DataMember]
            public string emailAddress { get; set; }
    
            [DataMember]
            public string eml_key { get; set; }
    
            [DataMember]
            public string eml_type { get; set; }
    
            [DataMember]
            public bool isInValid { get; set; }
    
            [DataMember]
            public bool isUnlisted { get; set; }
    
            [DataMember]
            public bool isPrimary { get; set; }
        }

    There is a method in my service that accepts CustomerEmailData as a parameter - so yes, it's being consumed there.  My web page has the following code:

    public partial class myaccount : System.Web.UI.Page
    {
        
        private SSOData varSSOData;
        private IndividualData varIndividualData;
        private CustomerAddressData varAddressData;
        private CustomerPhoneData varPhoneData;
        private CustomerEmailData varEmailData;

    where CustomerAddressData and CustomerPhoneData are happy - but I can't get CustomerEmailData to work?!  It's just like the service doesn't want to generate any more Data Contracts?!!!?!

    Frustrated.


    Jeff Miller ACFE - IT Architect

    Wednesday, September 18, 2013 6:15 PM
  • Wait - let me back track a bit.  While I had a method in my web service was using that CustomerEmailData as a parameter, I did NOT have a valid operationcontract in my interface (where the DataContract was also defined obviously) that was using this data contract.  I added the following:

     [OperationContract(Name = "AddNewEmailJsonWithPost")]
            [WebInvoke(Method = "POST",
                ResponseFormat = WebMessageFormat.Json,
                RequestFormat = WebMessageFormat.Json,
                BodyStyle = WebMessageBodyStyle.Bare,
                UriTemplate = "/addnewemailwithpost")]
            string xWebEmailInsertJson(CustomerEmailData requestData);

    rebuild my DLL, then refreshed the Service in my website and it now added the CustomerEmailData to the xsd and I can access that Data Contract.

    I find it a bit odd that a data contract alone will not show up in the xsd schema without it being consumed by a web method?  But - alas, after 2 days of beating my head against a wall, I've learned something...

    Thanks for your help "wagons" - just asking your questions sparked my brain to working...


    Jeff Miller ACFE - IT Architect

    Wednesday, September 18, 2013 6:34 PM
  • No problem.  In my experience, WCF will only define types in the XSDs which are exposed in one or more method signatures in the interface for the web service.  If your custom type is not used in the interface, WCF will ignore it.  I'm not sure why that should be the case, but it may be to minimize the amount of stuff in the XSDs.

    Wednesday, September 18, 2013 9:04 PM